package cn.estsh.i3plus.pojo.base.enumutil;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * @Description :
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2018-09-12 14:32
 * @Modify:
 **/
public class CommonEnumUtil {

    /**
     * 软件类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SOFT_TYPE {
        /** WMS 服务 */
        WMS(3, 8200, 10, 102000000L, "i3wms", "仓库管理软件"),
        SWEB(7, 8800, 19, 108000000L, "i3sweb", "供应商服务"),
        QMS(5, 0, 0, 0, "i3qms", "质量管理软件"),

        /** Mes 服务 */
        MES(4, 8300, 11, 103000000L, "i3mes", "生产管理软件"),
        MES_PCN(6, 8350, 12, 107000000L, "i3mes-pcn", "生产管理软件-节点中心"),

        /** PTL 服务 */
        PTL(8, 8700, 20, 111000000L, "i3ptl", "亮灯自动拣选"),
        PTL_PCN(9, 8750, 21, 109000000L, "i3ptl-pcn", "亮灯自动拣选-节点中心"),

        /** Block 服务 */
        FORM(20, 8900, 16, 104000000L, "block-form", "智能表单"),
        REPORT(21, 8910, 17, 105000000L, "block-report", "智能报表"),
        WORKFLOW(22, 0, 0, 0, "block-workflow", "智能工作流"),
        JOBFLOW(23, 0, 0, 0, "block-jobflow", "智能作业流"),
        SOFTSWITCH(24, 8920, 18, 130000000L, "block-softswitch", "软件适配器"),
        HARDSWITCH(25, 0, 0, 0, "block-hardswitch", "硬件适配器"),

        /** LAC 服务 */
        LAC(26, 8600, 13, 150000000L, "lac", "连接适配器"),

        /** 安灯服务 */
        ANDON(27, 8500, 14, 110000000L, "andon", "安灯"),

        /** 计划排产服务 */
        APS(28, 8400, 15, 140000000L, "i3aps", "高级计划与排产"),
        SURFACE(98, 0, 0, 0, "i3surface", "对外服务"),

        /** 基础服务 */
        IMPP(1, 0, 0, 100000000L, "impp-platform", "IMPP平台"),
        CONSOLE(95, 8010, 0, 0, "impp-console", "服务监控台"),
        GATEWAY(96, 9000, 0, 0, "impp-gateway", "服务网关"),
        CLOUD(97, 0, 0, 0, "i3cloud", "微服务"),
        CENTER(99, 8000, 1, 0, "icloud-server", "注册中心"),

        /** 平台服务 */
        CORE(2, 8100, 4, 101000000L, "i3core", "i3业务平台"),
        MDM(29, 8150, 22, 0, "i3mdm", "数据中心MDM"),

        /** 调试服务 */
        DEV(9999, 0000, 0, 120000000L, "Development", "系统调试");


        /** 产品ID */
        private int value;
        /** 应用默认端口 */
        private int port;
        /** 应用默认雪花DataBaseId(0-31)共32 个存储区 */
        private int snowflakeId;
        /** 产品代码 */
        private String code;
        /** 顶级菜单代码 */
        private long menuRootId;
        /** 产品描述 */
        private String description;

        SOFT_TYPE(int value, int port, int snowflakeId, long menuRootCode, String code, String description) {
            this.value = value;
            this.port = port;
            this.snowflakeId = snowflakeId;
            this.menuRootId = menuRootCode;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public int getPort() {
            return port;
        }

        public int getSnowflakeId() {
            return snowflakeId;
        }

        public long getMenuRootId() {
            return menuRootId;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static SOFT_TYPE codeOf(String code) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static SOFT_TYPE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static SOFT_TYPE valueOfMenuRootId(long id) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].menuRootId == id) {
                    return values()[i];
                }
            }
            return null;
        }

        public static SOFT_TYPE codeOfDescription(String code) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    return values()[i];
                }
            }
            return null;
        }
        public synchronized static int descriptionOfValue(String desc) {
            int tmp = IMPP.value;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                    break;
                }
            }
            return tmp;
        }
        public static int descOf(String desc) {
            int tmp = IMPP.value;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].name().equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 处理标识
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum TRUE_OR_FALSE {
        TRUE(1, "是"), FALSE(2, "否");

        private int value;
        private String description;

        private TRUE_OR_FALSE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getValueStr() {
            return value + "";
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static int boolOfOfVal(boolean boolVal) {
            return boolVal ? TRUE_OR_FALSE.TRUE.getValue() : TRUE_OR_FALSE.FALSE.getValue();
        }

        public static int intOfVal(int boolIntVal) {
            return boolIntVal == 1 ? TRUE_OR_FALSE.TRUE.getValue() : TRUE_OR_FALSE.FALSE.getValue();
        }

        public static TRUE_OR_FALSE valueOfEnum(int value){
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == value) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String valueOfDescription(int val) {return valueOf(val);}
        public static int descriptionOfValue(String desc) {return descOf(desc);}

        public static boolean valueOfBoolean(int val) {
            if(val == TRUE.value){
                return true;
            }else {
                return false;
            }
        }

    }

    /**
     * 处理标识
     */
    public enum IS_DEAL {
        YES(1, "已处理"), NO(2, "未处理");

        private int value;
        private String description;

        private IS_DEAL(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 处理标识
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SYS_LOCALE_RESOURCE_TYPE {
        COMMON(10, "通用"),
        EXCEPTION_DETAIL(20, "异常信息"),
        EXCEPTION_SOLUTION(30, "解决方案"),
        ENUM(40, "枚举"),
        MENU(50, "功能权限"),
        WEB(60, "前端"),
        SYS_CONFIG(70, "系统参数"),
        SYS_DICTIONARY(80, "系统字典"),
        MISSING(90, "缺失");

        private int value;
        private String description;

        private SYS_LOCALE_RESOURCE_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
        public static int descOf(String desc) {
            int tmp = COMMON.value;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
        public static String valueOfDescription(int val) {
            return valueOf(val);
        }
        public static int descriptionOfValue(String val) {
            return descOf(val);
        }
    }

    /**
     * 用户类型
     * user 通过权限设置分配权限
     * admin 包含所有模块及功能权限
     * sa 包含admin权限，以及后台管理权限
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum USER_TYPE {
        USER(1, "user", "普通用户"),
        ADMIN(2, "admin", "系统管理员"),
        SA(3, "sa", "超级管理员");

        private int value;
        private String code;
        private String description;

        private USER_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getCode() {
            return code;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static USER_TYPE valueOfCode(String code) {
            USER_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }

        public static USER_TYPE valueOfDescription(String description) {
            USER_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(description)) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 用户状态
     * 1正常
     * 2冻结
     * 3账号异常
     * 4离职
     * 5服务到期
     * 6锁定
     * 7启用
     * 8禁止
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum USER_STATUS {
//        EMPTY(1, "fa fa-success cell-fa fa-check", "正常"),
//        FREEZE(2, "冻结", "冻结_FREEZE"),
//        ABERRANT(3, "异常", "异常_ABERRANT"),
//        RESIGNATION(4, "离职", "离职_RESIGNATION"),
//        EXPIRE(5, "服务到期", "服务到期_EXPIRE"),
        LOCKING(3, "fa cell-fa fa-lock", "锁定"),
        ENABLE(1, "fa fa-success cell-fa fa-check", "启用"),
        DISABLE(2, "fa fa-disabled cell-fa fa-times-circle", "禁用");

        private int value;
        private String code;
        private String description;

        private USER_STATUS(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getCode() {
            return code;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            return valueOf(val);
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }
    /**
     * 数据类型
     * 1库存移动数据
     * 2质检数据
     * 3已配料待出库
     * 4JIS发运扣减
     * 5报工待汇总
     * 6报工汇总待处理
     * 7erp接口待同步
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum NUM_TYPE {
        MOVE_DETAILS(1, "MOVE_DETAILS", "库存移动数据"),
        QC_DETAILS(2, "QC_DETAILS", "质检数据"),
        DOC_MOVEMENT(3, "DOC_MOVEMENT", "已配料待出库"),
        DOC_SHIPPING(4, "DOC_SHIPPING", "JIS发运扣减"),
        FG_DETAILS(5, "FG_DETAILS", "报工待汇总"),
        FG_SUM(6, "FG_SUM", "报工汇总待处理"),
        ERP_INTERFACE(7, "ERP_INTERFACE", "ERP接口待同步");
        private int value;
        private String code;
        private String description;

        private NUM_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getCode() {
            return code;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum USER_INFO_STATUS {
        INCUMBENT(1, "正常", "正常_NORMAL"),
        RESIGNATION(2, "离职", "离职_RESIGNATION");

        private int value;
        private String code;
        private String description;

        private USER_INFO_STATUS(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getCode() {
            return code;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 数据状态
     *  1 启用
     *  2 禁用
     *  3 锁定
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DATA_STATUS {
        ENABLE(1, "启用", "fa fa-success cell-fa fa-check"),
        DISABLE(2, "禁用", "fa fa-disabled cell-fa fa-times-circle"),
        LOCKING(3, "锁定", "fa cell-fa fa-lock");

        private int value;
        private String name;
        private String description;

        DATA_STATUS() {
        }

        DATA_STATUS(int value, String name, String description) {
            this.value = value;
            this.name = name;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getName() {
            return name;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].getName();
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 功能级别
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum METHOD_LEVEL {
        PLUGIN(1, "插件"),
        MODULE(2, "顶级目录"),
        METHOD(3, "二级目录"),
        BUTTON(4, "按钮");

        private int value;
        private String description;

        private METHOD_LEVEL(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static METHOD_LEVEL get(int id){
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == id) {
                    return values()[i];
                }
            }
            return null;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 是否有效
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum IS_VAILD {
        VAILD(1, "有效"), INVAILD(2, "无效");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getValueStr() {
            return value + "";
        }

        public String getDescription() {
            return description;
        }

        private IS_VAILD(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 排序方式
     */
    public enum ASC_OR_DESC {
        ASC(1, "正序"), DESC(2, "倒序");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private ASC_OR_DESC(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 父节点配置
     */
    public enum PARENT{

        DEFAULT(-1L,"根节点");

        private Long value = -1L;
        private String description = null;

        public Long getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private PARENT(Long value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 性别
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum USER_ESX {
        MALE(1, "男"),
        FEMALE(2, "女");

        private int value;
        private String description;

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private USER_ESX(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 服务状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum CLOUD_APP_STATUS {
        UP(1,"UP" ,"在线"),
        DOWN(2, "DOWN","断线"),
        RESTRICTED(3,"RESTRICTED" ,"受限");

        private int value;
        private String code;
        private String description;

        private CLOUD_APP_STATUS(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 客户端登录标识
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum LOG_LOGIN_PLATFORM {
        PC_IMPP_CORE(10, "PC-IMPP", "PC后台管理端"),
        PC_WMS_SWEB(20, "PC-SWEB", "PC SWEB后台管理端"),
        Mobile_PDA(30, "Mobile-PDA", "移动设备PDA操作端"),
        MES_PCN(40, "MES-PCN", "MES-PCN"),
        PTL_PCN(50, "PTL-PCN", "PTL-PCN");

        private int value;
        private String name;
        private String description;

        LOG_LOGIN_PLATFORM() {
        }

        LOG_LOGIN_PLATFORM(int value, String name, String description) {
            this.value = value;
            this.name = name;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getName() {
            return name;
        }

        public static LOG_LOGIN_PLATFORM valueOf(int val) {
            LOG_LOGIN_PLATFORM tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }

        /**
         * -1 未识别操作系统
         * @param desc
         * @return
         */
        public static int descOf(String desc) {
            int tmp = -1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 用户登录状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum USER_LOGIN_STATUS {
        LOGIN_SUCCESS(1, "登录成功", "登录成功"),
        WRONG_PASSWORD(3, "密码错误", "用户密码错误"),
        WRONG_USERNAME_OR_PASSWORD(2, "用户名或密码错误", "用户名或密码错误"),
        USER_LOGIN_LOCKING(4, "账号已锁定", "账号已锁定"),
        USER_INFO_NULL(5, "用户信息不存在", "用户信息不存在"),
        SYSTEM_ERROR(6, "系统异常", "系统异常");

        private int value;
        private String name;
        private String description;

        USER_LOGIN_STATUS() {
        }

        USER_LOGIN_STATUS(int value, String name, String description) {
            this.value = value;
            this.name = name;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getName() {
            return name;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].getName();
                }
            }
            return tmp;
        }
        public static String valueOfDescription(int val) {
            return valueOf(val);
        }

        public static int descOf(String desc) {
            int tmp = -1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * Content-Type
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum CONTENT_TYPE {
        FORM("x-www-form-urlencoded", "表单"),
        FILE("multipart/form-data", "文件"),
        JSON("application/json", "JSON"),
        NONE("default", "默认不需要设置Content-Type"),
        XML("application/xml", "XML");

        private String value;
        private String description;

        public String getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        private CONTENT_TYPE(String value, String description) {
            this.value = value;
            this.description = description;
        }
        public static CONTENT_TYPE valueOfContenType(String val) {
            CONTENT_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (StringUtils.equalsIgnoreCase(values()[i].value, val)) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }

        public static String valueOfDescription(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (StringUtils.equalsIgnoreCase(values()[i].value, val)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String descriptionOfValue(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (StringUtils.equalsIgnoreCase(values()[i].description, val)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * HTTP 请求方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum HTTP_METHOD_TYPE {
        GET(1,"GET" ,"GET"),
        POST(2, "POST","POST"),
        DELETE(3, "DELETE","DELETE"),
        PUT(4, "PUT","PUT");

        private int value;
        private String code;
        private String description;

        private HTTP_METHOD_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static HTTP_METHOD_TYPE valueOf(int val) {
            HTTP_METHOD_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }
    }

    /**
     * 变量类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum  BASIS_TYPE {
        INT(1, "int"),
        DOUBLE(2, "double"),
        LONG(3, "long"),
        FLOAT(4, "float"),
        CHAR(5, "char"),
        BOOLEAN(6,"boolean"),
        BYTE(7, "byte"),
        SHORT(8, "short");

        private int value;
        private String description;

        private BASIS_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    // 数据有效的静态常量
    public static final int VALID = CommonEnumUtil.IS_VAILD.VAILD.getValue();
    // 数据未删除的静态常量
    public static final int FALSE = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();

    /**
     * 日志记录方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum LOG_DETAIL_SHOW_TYPE {
        DEBUG(1, "DEBUG"),
        OVER_TIME(2, "记录超时服务"),
        ALL_METHOD(3, "所有服务"),
        ALL_METHOD_PARAMETER(4, "所有服务和入参");

        private int value;
        private String description;

        private LOG_DETAIL_SHOW_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static LOG_DETAIL_SHOW_TYPE valueOfEnum(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }


    /**
     * 元素控件类型信息
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PROPERTY_CONTROL_TYPE {
        RADIO(100, "RADIO", "单选"),
        CHECKBOX(110, "CHECKBOX", "复选"),
        TEXT(200, "TEXT", "文本"),
        NUMBER(210, "NUMBER", "数字"),
        PASSWORD(230, "PASSWORD", "密码"),
        DATE_TIME(300, "DATE", "日期",SQL_WHERE.BETWEEN),
        //        DATE(300, "DATE", "日期(yyyy-MM-dd)"),
//        DATE_TIME(310, "DATE_TIME", "时间(yyyy-MM-dd hh:mm:ss)"),
        //        ELEMENT(700, "DICT_SELECT", "元素"),
        DICTIONARY(800, "DICT_SELECT", "字典"),
        CASCADE(900, "CASCADE", "级联"),
        PICK_UP(1000, "PICK_UP", "拾取"),
        INTERVAL(1100, "INTERVAL", "区间",SQL_WHERE.INTERVAL);
        //FILE(400, "file", "文件"),
        //IMAGE(410, "image", "image"),
        //OFF(500, "color", "颜色"),

        private int value;
        private String code;
        private String description;

        /**
         * 默认查询关系
         */
        private SQL_WHERE defaultWhere;

        PROPERTY_CONTROL_TYPE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        PROPERTY_CONTROL_TYPE(int value, String code, String description, SQL_WHERE defaultWhere) {
            this.value = value;
            this.code = code;
            this.description = description;
            this.defaultWhere = defaultWhere;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public SQL_WHERE getDefaultWhere() {
            return defaultWhere;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static PROPERTY_CONTROL_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 条件运算符
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SQL_WHERE {
        EQUAL(10, " = ", "等于"),
        NOT_EQUAL(11, " <> ", "不等于"),
        MORE(20, " > ", "大于"),
        LESS(30, " < ", "小于"),
        MORE_OR_EQUAL(21, " >= ", "大于等于"),
        LESS_OR_EQUAL (31, " <= ", "小于等于"),
        LIKE(40, " LIKE ", "全模糊"),
        START_LIKE(41, " LIKE ", "前模糊"),
        END_LIKE(52, " LIKE ", "后模糊"),
        IN(50, " IN ", " in "),
        BETWEEN(60, " BETWEEN ", "(between)区间查询(逗号区分)"),
        INTERVAL(70, ">=And=< ", "(>= =<)区间查询(逗号区分)");

        private int value;
        private String code;
        private String description;

        private SQL_WHERE(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code.toLowerCase())) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static SQL_WHERE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 缺失资源来源
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum MiSS_RESOURCE_SOURCE {
        WEB(10, "网页端"),
        SERVER(20, "服务端");

        private int value;
        private String description;

        private MiSS_RESOURCE_SOURCE(int value,  String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static MiSS_RESOURCE_SOURCE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }
    }

    /**
     * 属性类型信息(属性转换器)
     * <per>
     * <br/>    Form 核心转换器
     * <br/>    数据库字段类型转换Java 属性类型
     * <br/>    Java 属性 转换为控件类型
     * </per>
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PROPERTY_TYPE {
        STRING(10, "String", "字符串", "java.lang.String", String.class, PROPERTY_CONTROL_TYPE.TEXT, SQL_WHERE.LIKE, ""),
        CHAR(11, "Character", "单字符", "java.lang.Character", Character.class, PROPERTY_CONTROL_TYPE.TEXT, SQL_WHERE.EQUAL, ""),
        INTEGER(20, "Integer", "短整型", "java.lang.Integer", Integer.class, PROPERTY_CONTROL_TYPE.NUMBER, SQL_WHERE.EQUAL, "0"),
        LONG(21, "Long", "长整型", "java.lang.Long", Long.class, PROPERTY_CONTROL_TYPE.NUMBER, SQL_WHERE.EQUAL, "0"),
        DOUBLE(30, "Double", "大浮点型", "java.lang.Double", Double.class, PROPERTY_CONTROL_TYPE.NUMBER, SQL_WHERE.EQUAL, "0.0"),
        FLOAT(31, "Float", "小浮点型", "java.lang.Float", Float.class, PROPERTY_CONTROL_TYPE.NUMBER, SQL_WHERE.EQUAL, "0.0"),
        BIG_DECIMAL(32, "BigDecimal", "大浮点型", "java.math.BigDecimal", BigDecimal.class, PROPERTY_CONTROL_TYPE.NUMBER, SQL_WHERE.EQUAL, "0.0"),
        BOOLEAN(40, "Boolean", "布尔值", "java.lang.Boolean", Boolean.class, PROPERTY_CONTROL_TYPE.RADIO, SQL_WHERE.EQUAL, null),
        BYTE(50, "Byte", "字节", "java.lang.Byte", Byte.class, PROPERTY_CONTROL_TYPE.TEXT, SQL_WHERE.EQUAL, null),
        DATE_TIME(12, "String", "日期时分秒", "java.sql.Timestamp", Timestamp.class, PROPERTY_CONTROL_TYPE.DATE_TIME, SQL_WHERE.BETWEEN, null, "yyyy-MM-dd hh:mm:ss");

        /**
         * 属性类型值
         */
        private int value;
        /**
         * 属性类型代码
         */
        private String code;
        /**
         * 属性类型描述
         */
        private String description;
        /**
         * 属性类型ClassPath
         */
        private String classPath;
        /**
         * 属性类型 Class
         */
        private Class clzFullName;
        /**
         *  属性类型 对应的 控件类型
         */
        private PROPERTY_CONTROL_TYPE controlType;
        /**
         * 默认查询关系
         */
        private SQL_WHERE defaultWhere;
        /**
         * 默认 格式化 方式
         */
        private String defaultFormat;
        /**
         * 默认查询关系
         */
        private String defaultValue;

        private PROPERTY_TYPE(int value, String code, String description,String classPath,Class clzFullName,
                              PROPERTY_CONTROL_TYPE controlType,SQL_WHERE defaultWhere) {
            this.value = value;
            this.code = code;
            this.description = description;
            this.classPath = classPath;
            this.clzFullName = clzFullName;
            this.controlType = controlType;
            this.defaultWhere = defaultWhere;
        }

        private PROPERTY_TYPE(int value, String code, String description,String classPath,Class clzFullName,
                              PROPERTY_CONTROL_TYPE controlType,SQL_WHERE defaultWhere,String defaultValue) {
            this.value = value;
            this.code = code;
            this.description = description;
            this.classPath = classPath;
            this.clzFullName = clzFullName;
            this.controlType = controlType;
            this.defaultWhere = defaultWhere;
            this.defaultValue = defaultValue;
            this.defaultFormat = defaultFormat;
        }

        private PROPERTY_TYPE(int value, String code, String description,String classPath,Class clzFullName,
                              PROPERTY_CONTROL_TYPE controlType,SQL_WHERE defaultWhere,String defaultValue,String defaultFormat) {
            this.value = value;
            this.code = code;
            this.description = description;
            this.classPath = classPath;
            this.clzFullName = clzFullName;
            this.controlType = controlType;
            this.defaultWhere = defaultWhere;
            this.defaultValue = defaultValue;
            this.defaultFormat = defaultFormat;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public String getClassPath() {
            return classPath;
        }

        public Class getClzFullName() {
            return clzFullName;
        }

        public PROPERTY_CONTROL_TYPE getControlType() {
            return controlType;
        }

        public SQL_WHERE getDefaultWhere() {
            return defaultWhere;
        }

        public String getDefaultFormat() {
            return defaultFormat;
        }

        public String getDefaultValue() {
            return defaultValue;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static PROPERTY_TYPE valueOfClzFullName(int val) {
            PROPERTY_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }


        public static PROPERTY_CONTROL_TYPE valueOfControlType(int val) {
            PROPERTY_CONTROL_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].controlType;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static int codeOfClzFullName(Class clzFullName) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].clzFullName.equals(clzFullName)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static int codeOfClassPath(String classPath) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].classPath.equals(classPath)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static PROPERTY_TYPE valueOfClassPath(String classPath) {
            PROPERTY_TYPE tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].classPath.equals(classPath)) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }

        public static PROPERTY_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static PROPERTY_TYPE indexOf(String val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (val.indexOf(values()[i].value) >= 0) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }


    /**
     * 数据库连接方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DATA_SOURCE_TYPE {
        SOURCE_MARIA_DB(100, "MariaDB", "MariaDB 10.1","com.mysql.jdbc.Driver",3306,null),
        SOURCE_SQL_SERVER(200, "SQL Server", "SQL Server 2017","com.microsoft.sqlserver.jdbc.SQLServerDriver",1433,"dbo"),
        SOURCE_ORACLE(300, "Oracle", "Oralce 12C","oracle.jdbc.driver.OracleDriver",1521,null),
        SOURCE_POSTGRE_SQL(400, "PostgreSql", "PostgreSql 10.5","org.postgresql.Driver",5432,"public"),
        SOURCE_SAP_HANA(500, "SapHana", "SapHana","com.sap.db.jdbc.Driver",39015,null);

        private int value;
        private String code;
        private String description;
        private String driverClassName;
        private int defaultPort;
        private String defaultSchemaPattern;

        private DATA_SOURCE_TYPE (int value, String code, String description,String driverClassName,int port,String defaultSchemaPattern) {
            this.value = value;
            this.code = code;
            this.description = description;
            this.driverClassName = driverClassName;
            this.defaultPort = port;
            this.defaultSchemaPattern = defaultSchemaPattern;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public String getDriverClassName() {
            return driverClassName;
        }

        public int getDefaultPort() {
            return defaultPort;
        }

        public String getDefaultSchemaPattern() {
            return defaultSchemaPattern;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static DATA_SOURCE_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public String getSchemaPattern(String schema) {
            if(this.equals(SOURCE_SAP_HANA)){
                return schema;
            }
            return defaultSchemaPattern;
        }

        public String getJDBCUrl(String database,String host,Integer port){
            if(this.getValue() == SOURCE_MARIA_DB.getValue()){
                return getJDBCUrlMySQL(database,host,port);
            }else if(this.getValue() == SOURCE_ORACLE.getValue()){
                return getJDBCUrlOracle(database,host,port);
            }else if(this.getValue() == SOURCE_POSTGRE_SQL.getValue()){
                return getJDBCUrlPostgreSQL(database,host,port);
            }else if(this.getValue() == SOURCE_SQL_SERVER.getValue()){
                return getJDBCUrlSQLServer(database,host,port);
            }else if(this.getValue() == SOURCE_SAP_HANA.getValue()){
                return getJDBCUrlSapHana(database,host,port);
            }
            return null;
        }

        public String getJDBCUrl(String database,String host,Integer port,String instanceName){
            if(this.getValue() == SOURCE_MARIA_DB.getValue()){
                return getJDBCUrlMySQL(database,host,port);
            }else if(this.getValue() == SOURCE_ORACLE.getValue()){
                return getJDBCUrlOracle(database,host,port);
            }else if(this.getValue() == SOURCE_POSTGRE_SQL.getValue()){
                return getJDBCUrlPostgreSQL(database,host,port);
            }else if(this.getValue() == SOURCE_SQL_SERVER.getValue()){
                return getJDBCUrlSQLServer(database,host,port,instanceName);
            }
            return null;
        }

        public static DATA_SOURCE_TYPE getDataSourceURL(String databaseProductName){
            if(StringUtils.isNotBlank(databaseProductName)){
                if(databaseProductName.indexOf(":mysql:") != -1){
                    return SOURCE_MARIA_DB;
                }else if(databaseProductName.indexOf(":oracle:") != -1){
                    return SOURCE_ORACLE;
                }else if(databaseProductName.indexOf(":postgresql:") != -1){
                    return SOURCE_POSTGRE_SQL;
                }else if(databaseProductName.indexOf(":sqlserver:") != -1){
                    return SOURCE_SQL_SERVER;
                }else if(databaseProductName.indexOf(":sap:") != -1){
                    return SOURCE_SAP_HANA;
                }
            }
            return null;
        }


        // cn.estsh.i3plus.mes.pcn.util.BsJdbcTemplateConfigTest
        private String getJDBCUrlMySQL(String database,String host,Integer port){
            // 针对mysql 8.0 先加上allowPublicKeyRetrieval 赋予默认时区CST
            return "jdbc:mysql://"+host+":"+port+"/"+database+
                    "?autoReconnect=true" +
                    "&useSSL=false" +
                    "&characterEncoding=utf-8" +
                    "&allowPublicKeyRetrieval=true" +
                    "&serverTimezone=CST";
        }

        private String getJDBCUrlOracle(String database,String host,Integer port){
            return "jdbc:oracle:thin:@"+host+":"+port+":"+database;
        }

        private String getJDBCUrlPostgreSQL(String database,String host,Integer port){
            return "jdbc:postgresql://"+host+":"+port+"/"+database;
        }

        private String getJDBCUrlSQLServer(String database,String host,Integer port){
            return "jdbc:sqlserver://" + host + ":" + port + ";database=" + database+";autoReconnect=true";
        }

        private String getJDBCUrlSapHana(String database,String host,Integer port){
            return "jdbc:sap://" + host + ":" + port + "?reconnect=true";
        }

        private String getJDBCUrlSQLServer(String database,String host,Integer port,String instanceName){
            StringBuffer sb = new StringBuffer();
            sb.append("jdbc:sqlserver://").append(host);
            // 实例
            if (StringUtils.isNotBlank(instanceName)) {
                sb.append("\\").append(instanceName);
            }
            //  端口
            sb.append(":").append(port);
            // 数据库
            sb.append(";database=").append(database);
            // 自动重连
            sb.append(";autoReconnect=true");
            return sb.toString();
        }
    }

    /**
     * 变量类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum  LICENSE_SOURCE {
        LOCAL_SYSTEM_FILE(1, "本地文件"),
        NETWORK_ESTSH(2, "网络-官方授权"),
        SENSE_HARDWARE_USB_LOCK(3, "硬件锁"),
        SENSE_SOFTWARE_CODE_LOCK(4, "软锁");

        private int value;
        private String description;

        private LICENSE_SOURCE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DAO_OPERATE_TYPE {
        INSERT(1, "新增"),
        DELETE(2, "删除"),
        UPDATE(3, "修改"),
        SELECT(4, "查询");

        private int value;
        private String description;

        private DAO_OPERATE_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * actuator env
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ACTUATOR_ENV_PATH {
        PID(1,"/PID" ,"PID"),
        JAVA_VERSION(2, "/java.version","jdk版本");

        private int value;
        private String path;
        private String description;

        private ACTUATOR_ENV_PATH(int value, String path, String description) {
            this.value = value;
            this.path = path;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getPath() {
            return path;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfPath(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].path;
                }
            }
            return tmp;
        }

        public static int pathOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].path.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String pathOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].path.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * actuator env
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum ACTUATOR_METRICS_INFO {
        UPTIME(1, "/process.uptime", "上线时间"),
        PROCESS_CPU_USAGE(1, "/process.cpu.usage", "进程CPU使用率"),
        CPU_COUNT(1, "/system.cpu.count", "CPU数量"),
        SYSTEM_CPU_USAGE(1, "/system.cpu.usage", "系统CPU使用率"),
        GC_PAUSE(1, "/jvm.gc.pause", "GC暂停"),
        THREADS_LIVE(1, "/jvm.threads.live", "实时线程"),
        THREADS_PEAK(1, "/jvm.threads.peak", "线程峰值"),
        THREADS_DAEMON(1, "/jvm.threads.daemon", "守护线程"),

        MEMORY_HEAP_MAX(1, "/jvm.memory.max", "area:heap", "堆内存最大空间"),
        MEMORY_HEAP_USE(1, "/jvm.memory.used", "area:heap", "堆内存使用量"),
        MEMORY_HEAP_SIZE(1, "/jvm.memory.committed", "area:heap", "堆内存大小"),

        MEMORY_NON_HEAP_MAX(1, "/jvm.memory.max", "area:nonheap", "非堆内存最大空间"),
        MEMORY_NON_HEAP_USE(1, "/jvm.memory.used", "area:nonheap", "非堆内存"),
        MEMORY_NON_HEAP_METASPACE(1, "/jvm.memory.used", "area:nonheap,id:Metaspace", "非堆原空间"),
        MEMORY_NON_HEAP_SIZE(1, "/jvm.memory.committed", "area:nonheap", "非堆大小");

        private int value;
        private String path;
        private String tag;
        private String description;

        private ACTUATOR_METRICS_INFO(int value, String path, String description) {
            this.value = value;
            this.path = path;
            this.description = description;
        }

        private ACTUATOR_METRICS_INFO(int value, String path, String tag,  String description) {
            this.value = value;
            this.path = path;
            this.tag = tag;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getPath() {
            return path;
        }
        public String getTag() {
            return tag;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfPath(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].path;
                }
            }
            return tmp;
        }

        public static int pathOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].path.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static String pathOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].path.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DATA_SOURCE_STATUS {
        CONN_SUCCESS(10, "验证成功", "验证成功"),
        CONN_FAILURE(20, "验证失败", "验证失败");
//        TIME_OUT(30, "连接超时", "连接超时"),
//        AUTH_ERROR(40, "账号密码错误", "账号密码错误");

        private int value;
        private String code;
        private String description;

        private DATA_SOURCE_STATUS (int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }



        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static DATA_SOURCE_STATUS valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }


    /**
     * PC自定义搜索-字段类型
     * 10-文本，20-数字，30-下拉框，40，时间，50-开窗
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum FIELD_TYPE {
        TEXT(10, "text"), NUMBER(20, "number"),
        SELECT(30, "select"), DATETIME(40, "datetime"),
        LIST(50, "list");

        private int value;
        private String description;

        FIELD_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descriptionOfValue(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static FIELD_TYPE codeOf(Integer value) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == value) {
                    return values()[i];
                }
            }
            return null;
        }
    }

    /**
     * PC自定义搜索-取值方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DYNAMIC_FIELD_GET_WAY {
        ENUM(10, "SINGLE_OBJ", "枚举"),
        OBJ(20, "MULTIPLE_OBJ", "对象"),
        URL(30, "SINGLE_OBJ", "接口");

        private int value;
        private String code;
        private String description;

        DYNAMIC_FIELD_GET_WAY(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getCode() {
            return code;
        }

        public static DYNAMIC_FIELD_GET_WAY codeOf(int value) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == value) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static int descOf(String desc) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }



    /**
     * 业务表：库存条码质检状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum STOCK_SN_QC_STATUS {
        NORMAL(10, "NORMAL", "合格"), ABNORMAL(20, "ABNORMAL", "不合格"),
        ISOLATED(30, "ISOLATED", "隔离"), FRAZE(40, "FRAZE", "报废");

        private int value;
        private String code;
        private String description;

        STOCK_SN_QC_STATUS(int value, String code, String description) {
            this.value = value;
            this.code = code;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getCode() {
            return code;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static Integer descriptionOfValue(String desc) {
            Integer tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static CommonEnumUtil.STOCK_SN_QC_STATUS codeOf(Integer value) {
            if (value == null) {
                return null;
            } else {
                for (int i = 0; i < values().length; i++) {
                    if (values()[i].value == value) {
                        return values()[i];
                    }
                }
            }
            return null;
        }
    }


    /**
     * 业务表：库存条码状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum STOCK_SN_STATUS {
        CREATE(10, "创建"),
        QUALITY_CONTROL(20, "质检中"),
        PRE_INSTOCK(30, "待入库"),
        INSTOCKED(40, "入库"),
        PICKED(50, "配料"),
        OUT_STOCK(60, "出库"),
        SCRAP(70, "报废"),
        COMMING(80, "在途");

        private int value;
        private String description;

        STOCK_SN_STATUS(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }


        public static Integer descriptionOfValue(String desc) {
            Integer tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 业务表：库存条码状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DYNAMIC_DATA_SOURCE_TYPE {
        MASTER,NODE
    }

    /**
     * 会话模式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SESSION_MODE {
        DEFAULT(10, "默认"),
        OVERWRITE(20, "覆盖"),
        SEIZE(30, "抢占");

        private int value;
        private String description;

        SESSION_MODE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }


        public static Integer descriptionOfValue(String desc) {
            Integer tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 条码解析校验模式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum BARCODE_CHECK_MODE {
        SEPARATOR_NUM(10, "分割数"),
        ANALYTIC_NUM(20, "解析数"),
        WEAK(30, "弱校验");

        private int value;
        private String description;

        BARCODE_CHECK_MODE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }


        public static Integer descriptionOfValue(String desc) {
            Integer tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }



}
