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

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description : 模块报表枚举类
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2018-12-25 21:08
 * @Modify:
 **/
public class BlockReportEnumUtil {


    /**
     * 报表元素枚举
     * WORDS(1,"文字"),PIC(2,"图片"),REPORT(3,"报表");
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum REPORT_ELEMENT_TYPE{

        WORDS(1,"文字"),PIC(2,"图片");

        private int value;
        private String description;

        REPORT_ELEMENT_TYPE() {
        }

        REPORT_ELEMENT_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;
        }

    }

    /**
     * 报表布局枚举
     * TABLE(1,"表格"),CHART(2,"图表");
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum REPORT_LAYOUT_TYPE{

        TABLE(1,"表格"),CHART(2,"图表");

        private int value;
        private String description;

        REPORT_LAYOUT_TYPE() {
        }

        REPORT_LAYOUT_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;
        }
    }

    /**
     * 功能级别
     */
    @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 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");

        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;
        }
    }

    /**
     * 模板状态
     *  1 新建模板
     *  2 新建模板对象
     *  3 新建模板查询条件
     *  4 新建模板分组条件
     *  5 新建模板聚合条件
     *  6 新建模板显示条件
     *  7 新建模板确认
     *  8 新建模板完成
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum TEMPLATE_STATUS {
        SAVE_TEMPLATE(1, "新建模板", "新建模板"),
        SAVE_TEMPLATE_POJO(2, "新建模板对象", "新建模板对象"),
        SAVE_TEMPLATE_ATTR_WHERE(3, "新建模板查询条件", "新建模板查询条件"),
        SAVE_TEMPLATE_ATTR_GROUP(4, "新建模板分组条件", "新建模板分组条件"),
        SAVE_TEMPLATE_ATTR_AGGREGATION(5, "新建模板聚合条件", "新建模板聚合条件"),
        SAVE_TEMPLATE_ATTR_SHOW(6, "新建模板显示条件", "新建模板显示条件"),
        SAVE_TEMPLATE_ATTR_CONFIRM(7, "新建模板确认条件", "新建模板确认条件"),
        SAVE_TEMPLATE_FULFIL(8, "新建模板确认条件", "新建模板确认条件");

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

        TEMPLATE_STATUS() {
        }

        TEMPLATE_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 TEMPLATE_STATUS enumOf(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].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    /**
     * 数据状态
     *  1 启用
     *  2 禁用
     *  3 锁定
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum TEMPLATE_TYPE {
        TABLE(1, "表格", "表格模板"),
        ECHARTS_PIE(10, "饼图", "实芯饼图"),
        ECHARTS_BAR(20, "柱状图", "柱状图-向上具状图"),
        ECHARTS_LINE(30, "折线图", "向右折线条图"),
        ECHARTS_TREEMAP(40, "矩形图", "矩形图"),
        SELECT_SINGLE(50, "下拉单选", "下拉单选");

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

        TEMPLATE_TYPE() {
        }

        TEMPLATE_TYPE(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 TEMPLATE_TYPE enumOf(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].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String[] getChartAttrs(TEMPLATE_TYPE type){
            if(type != null){

//                TABLE(1, "表格", "表格模板"),
//                        ECHARTS_PIE(10, "饼图", "实芯饼图"),
//                        ECHARTS_BAR(20, "柱状图", "柱状图-向上具状图"),
//                        ECHARTS_LINE(30, "折线图", "向右折线条图"),
//                        ECHARTS_TREEMAP(40, "矩形图", "矩形图");
                if(type.equals(TEMPLATE_TYPE.TABLE)){       // Table 是可以编辑的 所以不需要指定列
                    return null;
                }else if(type.equals(TEMPLATE_TYPE.ECHARTS_PIE)){       // 饼图  只需要名称 和值
                    return new String[]{"name","value"};
                }else if(type.equals(TEMPLATE_TYPE.ECHARTS_BAR)){       // 饼图  只需要名称 和值
                    return new String[]{"name","value"};
                }else if(type.equals(TEMPLATE_TYPE.ECHARTS_LINE)){       // 饼图  只需要名称 和值
                    return new String[]{"xAxis","name","value"};
                }else if(type.equals(TEMPLATE_TYPE.ECHARTS_TREEMAP)){       // 饼图  只需要名称 和值
                    return new String[]{"name","value"};
                }
            }
            return null;
        }

    }

    /**
     * 表单样式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum TEMPLATE_STYLE {

        TABLE_LEFT(1, TEMPLATE_TYPE.TABLE, "text-align: left!important;", "表单左对齐"),
        TABLE_RIGHT(2, TEMPLATE_TYPE.TABLE, "text-align: right!important;", "表单右对齐"),
        TABLE_CENTER(3, TEMPLATE_TYPE.TABLE, "text-align: center!important;", "表单居中");

        private int value;
        private TEMPLATE_TYPE group;
        private String name;
        private String description;

        TEMPLATE_STYLE() {
        }

        TEMPLATE_STYLE(int value,TEMPLATE_TYPE group, String name, String description) {
            this.value = value;
            this.group = group;
            this.name = name;
            this.description = description;
        }

        public static TEMPLATE_STYLE[] getGroup(TEMPLATE_TYPE type){
            if(type != null){
                List<TEMPLATE_STYLE> list = new ArrayList<>();
                for (TEMPLATE_STYLE style : TEMPLATE_STYLE.values()) {
                    if(style.group.equals(type)){
                        list.add(style);
                    }
                }
                return list.toArray(new TEMPLATE_STYLE[list.size()]);
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getName() {
            return name;
        }

        public static TEMPLATE_STYLE valueOf(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].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }
//
//    /**
//     * HQL WHERE 条件
//     */
//    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
//    public enum HQL_WHERE{
//
//        GT(1, " > ", "大于"),
//        GT_EQUAL(2, " >= ", "大于等于"),
//        LT(3, " < ", "小于等于"),
//        LT_EQUAL(4, " <= ", "小于等于"),
//        LIKE(5, " LIKE ", "模糊"),
//        LIKE_LEFT(6, " LIKE ", "左模糊"),
//        LIKE_RIGHT(7, " LIKE ", "右模糊"),
//        EQUAL(8, " = ", "等于"),
//        EQUAL_NOT(9, " <> ", "不等于"),
////        AND(10, " AND ", "AND"),
////        OR(11, " OR ", "OR"),
////        NOT(12, " NOT ", "NOT"),
//        IN(8, " IN ", "IN"),
//        IS_NULL(13, " IS NULL ", "IS NULL"),
//        IS_NOT_NULL(14, " IS NOT NULL ", "IS NOT NULL");
//
//        private int value;
//        private String name;
//        private String description;
//
//        HQL_WHERE() {
//        }
//
//        HQL_WHERE(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 HQL_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 valueOfDescription(int val) {
//            for (int i = 0; i < values().length; i++) {
//                if (values()[i].value == val) {
//                    return values()[i].getDescription();
//                }
//            }
//            return null;
//        }
//
//        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 HQL_WHERE_REF{
        AND(10, " AND ", "AND"),
        OR(11, " OR ", "OR");

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

        HQL_WHERE_REF() {
        }

        HQL_WHERE_REF(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 HQL_WHERE_REF valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

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

        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 HQL_REF{
        LEFT_JOIN(1, " LEFT JOIN ", "左连接"),
        RIGHT_JOIN(2, " RIGHT JOIN ", "右连接"),
        INNER_JOIN(3, " INNER JOIN ", "内连接");

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

        HQL_REF() {
        }

        HQL_REF(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 HQL_REF valueOf(int val) {
            HQL_REF tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

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

        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 HQL_AGGREGATION{

        AVG(1, "AVG", "平均值"),
        MIN(2, "MIN", "最小值"),
        MAX(3, "MAX", "最大值"),
        SUM(4, "SUM", "总和"),
        COUNT(5, "COUNT", "计数");

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

        HQL_AGGREGATION() {
        }

        HQL_AGGREGATION(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 HQL_AGGREGATION valueOf(Integer val) {
            if(val != null){
                for (int i = 0; i < values().length; i++) {
                    if (values()[i].value == val.intValue()) {
                        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].name.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum HQL_ATTR_DATA_TYPE{
        SHOW(1, "show", "显示"),
        WHERE(2, "where", "查询"),
        GROUP(3, "group", "分组"),
        AGGREGATION(4, "聚合", "聚合"),
        ORDER(5, "order", "排序");

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

        HQL_ATTR_DATA_TYPE() {
        }

        HQL_ATTR_DATA_TYPE(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 HQL_ATTR_DATA_TYPE valueOf(Integer val) {
            if(val != null){
                for (int i = 0; i < values().length; i++) {
                    if (values()[i].value == val.intValue()) {
                        return values()[i];
                    }
                }
            }
            return null;
        }

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


        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;
        }
    }

    /**
     * 报表排版枚举
     * ELEMENT(1,"元素"),TEMPLATE(2,"对象视图");
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum REPORT_REF_TYPE{

        ELEMENT(1,"元素"),TEMPLATE(2,"对象视图");

        private int value;
        private String description;

        REPORT_REF_TYPE() {
        }

        REPORT_REF_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;
        }

    }


    /**
     * Echarts Pie
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum VIEW_ECHARTS_PIE_OPTION{
        OPTION_NAME(1,"ECHARTS_PIE_NAME","显示名称"),
        OPTION_VALUE(2,"ECHARTS_PIE_VALUE","显示内容");

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

        VIEW_ECHARTS_PIE_OPTION() {
        }

        VIEW_ECHARTS_PIE_OPTION(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 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;
        }

    }

    /**
     * Echarts Line
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum VIEW_ECHARTS_LINE_OPTION{
        OPTION_NAME(1,"ECHARTS_LINE_NAME","显示名称"),
        OPTION_VALUE(2,"ECHARTS_LINE_VALUE","显示内容"),
        OPTION_X_AXIS(3,"ECHARTS_LINE_X_AXIS","显示内容xAxis");

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

        VIEW_ECHARTS_LINE_OPTION() {
        }

        VIEW_ECHARTS_LINE_OPTION(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 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;
        }

    }

    /**
     * Echarts Bar
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum VIEW_ECHARTS_BAR_OPTION{
        OPTION_NAME(1,"ECHARTS_BAR_NAME","显示名称"),
        OPTION_VALUE(2,"ECHARTS_BAR_VALUE","显示内容");

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

        VIEW_ECHARTS_BAR_OPTION() {
        }

        VIEW_ECHARTS_BAR_OPTION(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 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;
        }

    }

    /**
     * Echarts TreeMap
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum VIEW_ECHARTS_TREEMAP_OPTION{
        OPTION_NAME(1,"ECHARTS_TREEMAP_NAME","显示名称"),
        OPTION_VALUE(2,"ECHARTS_TREEMAP_VALUE","显示内容");

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

        VIEW_ECHARTS_TREEMAP_OPTION() {
        }

        VIEW_ECHARTS_TREEMAP_OPTION(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 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;
        }

    }

}
