package com.yihu.wlyy.statistics.job.business;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2016.08.18.
 * 常量类
 */
public class Constant {
    public static String quota_date_last = " 17:00:00 ";
    public static String city = "350200";
    public static String cityName = "厦门市";
    //二级维度的性别
    public static String level_sex_1 = "1";
    public static String level_sex_2 = "2";
    public static String level_sex_3 = "3";
    public static String level_sex_1_name = "女";
    public static String level_sex_2_name = "男";
    public static String level_sex_3_name = "未知";

    //二级维度的年龄
    public static String level_age_1 = "1";
    public static String level_age_2 = "2";
    public static String level_age_3 = "3";
    public static String level_age_4 = "4";
    public static String level_age_5 = "5";
    public static String level_age_6 = "6";
    public static String level_age_1_name = "0~6";
    public static String level_age_2_name = "7~18";
    public static String level_age_3_name = "19~30";
    public static String level_age_4_name = "31~50";
    public static String level_age_5_name = "51~65";
    public static String level_age_6_name = ">65";

    //二级维度的年龄
    public static String level_age2_1 = "1";
    public static String level_age2_2 = "2";
    public static String level_age2_1_name = "<=65";
    public static String level_age2_2_name = ">65";

    //二级维度的组
    public static String level_group_0 = "0";
    public static String level_group_1 = "1";
    public static String level_group_2 = "2";
    public static String level_group_3 = "3";
    public static String level_group_4 = "4";
    public static String level_group_5 = "5";
    public static String level_group_6 = "6";
    public static String level_group_7 = "7";
    public static String level_group_0_name = "未分組";
    public static String level_group_1_name = "普通人群";
    public static String level_group_2_name = "慢病65岁以下人群";
    public static String level_group_3_name = "65岁以上人群";
    public static String level_group_4_name = "高血压";
    public static String level_group_5_name = "糖尿病";
    public static String level_group_6_name = "糖尿病和高血压";
    public static String level_group_7_name = "慢病65岁以上人群";


    //二级维度签约扣费
    public static String level_expense_0 = "0";
    public static String level_expense_1 = "1";
    public static String level_expense_2 = "2";
    public static String level_expense_0_name = "未缴费人数";
    public static String level_expense_1_name = "已缴费人数";
    public static String level_expense_2_name = "已退费";

    //二级维度健康分布
    public static String level_health_fb_0 = "0";
    public static String level_health_fb_1 = "1";
    public static String level_health_fb_2 = "2";
    public static String level_health_fb_3 = "3";
    public static String level_health_fb_4 = "4";
    public static String level_health_fb_0_name = "未标注";
    public static String level_health_fb_1_name = "健康人群";
    public static String level_health_fb_2_name = "患病人群";
    public static String level_health_fb_3_name = "高危人群";
    public static String level_health_fb_4_name = "恢复期人群";

    //二姐维度的年龄疾病

    public static String level_age_disease_1 = "1";
    public static String level_age_disease_2 = "2";
    public static String level_age_disease_3 = "3";
    public static String level_age_disease_1_name = "高血压";
    public static String level_age_disease_2_name = "糖尿病";
    public static String level_age_disease_3_name = "65岁以上";

    //耳机维度的时间分布
    public static String level_reply_time_1 = "1";
    public static String level_reply_time_2 = "2";
    public static String level_reply_time_3 = "3";
    public static String level_reply_time_4 = "4";
    public static String level_reply_time_5 = "5";
    public static String level_reply_time_1_name = "0-8";
    public static String level_reply_time_2_name = "8-12";
    public static String level_reply_time_3_name = "12-13";
    public static String level_reply_time_4_name = "13-18";
    public static String level_reply_time_5_name = "18-24";


    public static String level_sign_reason_1 = "1";
    public static String level_sign_reason_2 = "2";
    public static String level_sign_reason_3 = "3";
    public static String level_sign_reason_4 = "4";
    public static String level_sign_reason_5 = "5";
    public static String level_sign_reason_6 = "6";
    public static String level_sign_reason_1_name = "常住地变更";
    public static String level_sign_reason_2_name = "医生专业度不够";
    public static String level_sign_reason_3_name = "咨询回复慢";
    public static String level_sign_reason_4_name = "无获得感";
    public static String level_sign_reason_5_name = "医生服务态度差";
    public static String level_sign_reason_6_name = "其它";


    //三级维度的疾病
    public static String level_disease_1 = "1";
    public static String level_disease_2 = "2";
    public static String level_disease_3 = "3";
    public static String level_disease_4 = "4";
    public static String level_disease_1_name = "高血压";
    public static String level_disease_2_name = "糖尿病";
    public static String level_disease_3_name = "糖尿病和高血压";
    public static String level_disease_4_name = "健康人群";


    public static String getlevelHealthFbName(String key) {
        switch (key) {
            case "1": {
                return level_health_fb_1_name;
            }
            case "2": {
                return level_health_fb_2_name;
            }
            case "3": {
                return level_health_fb_3_name;
            }
            case "4": {
                return level_health_fb_4_name;
            }
            case "0": {
                return level_health_fb_0_name;
            }
        }
        return "";
    }

    public static String getLevelAge2(String key) {
        switch (key) {
            case "1": {
                return level_age2_1_name;
            }
            case "2": {
                return level_age2_2_name;
            }
        }
        return "";
    }

    public static String getLevelExpenseName(String key) {
        switch (key) {
            case "1": {
                return level_expense_1_name;
            }
            case "2": {
                return level_expense_2_name;
            }
            case "0": {
                return level_expense_0_name;
            }
        }
        return "";
    }

    public static String getLevelSexName(String key) {
        switch (key) {
            case "1": {
                return level_sex_1_name;
            }
            case "2": {
                return level_sex_2_name;
            }
            case "3": {
                return level_sex_3_name;
            }
        }
        return "";
    }

    public static String getLevelGroupName(String key) {
        switch (key) {
            case "0": {
                return level_group_0_name;
            }
            case "1": {
                return level_group_1_name;
            }
            case "2": {
                return level_group_2_name;
            }
            case "3": {
                return level_group_3_name;
            }
            case "4": {
                return level_group_4_name;
            }
            case "5": {
                return level_group_5_name;
            }
            case "6": {
                return level_group_6_name;
            }
            case "7": {
                return level_group_7_name;
            }
        }
        return "";
    }

    public static String getLevelAgeName(String key) {
        switch (key) {
            case "1": {
                return level_age_1_name;
            }
            case "2": {
                return level_age_2_name;
            }
            case "3": {
                return level_age_3_name;
            }
            case "4": {
                return level_age_4_name;
            }
            case "5": {
                return level_age_5_name;
            }
            case "6": {
                return level_age_6_name;
            }
        }
        return "";
    }

    public static String getLevelDiseaseName(String key) {
        switch (key) {
            case "1": {
                return level_disease_1_name;
            }
            case "2": {
                return level_disease_2_name;
            }
            case "3": {
                return level_disease_3_name;
            }
            case "4": {
                return level_disease_4_name;
            }
        }
        return "";
    }

    public static String getLevelAgeDiseaseName(String key) {
        switch (key) {
            case "1": {
                return level_age_disease_1_name;
            }
            case "2": {
                return level_age_disease_2_name;
            }
            case "3": {
                return level_age_disease_3_name;
            }
        }
        return "";
    }

    public static String getLevelReplyTimeName(String key) {
        switch (key) {
            case "1": {
                return level_reply_time_1_name;
            }
            case "2": {
                return level_reply_time_2_name;
            }
            case "3": {
                return level_reply_time_3_name;
            }
            case "4": {
                return level_reply_time_4_name;
            }
            case "5": {
                return level_reply_time_5_name;
            }
        }
        return "";
    }

    public static String getStartTime() throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date today = new Date();
        String todayString = simpleDateFormat.format(today);


        String startDateString = (1900 + today.getYear()) + "-07-01";
        Date startDate = simpleDateFormat.parse(startDateString);
        if (simpleDateFormat.parse(todayString).after(startDate)) {
            Integer year = (1900 + today.getYear());
            if (year == 2016) {
                return "2015-06-30";
            } else {
                return year+ "-06-30";
            }
        } else {
            Integer year =  (1900 + today.getYear() - 1);
            if (year == 2016) {
                return "2015-06-30";
            } else {
                return year+ "-06-30";
            }
        }
    }

    /**
     * 根据传入的时间判断年度
     * @param todayString
     * @return
     * @throws ParseException
     */
    public static String getStartTimeByDate(String todayString) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date today = simpleDateFormat.parse(todayString);

        String startDateString = (1900 + today.getYear()) + "-07-01";
        Date startDate = simpleDateFormat.parse(startDateString);
        if (simpleDateFormat.parse(todayString).after(startDate)) {
            Integer year = (1900 + today.getYear());
            if (year == 2016) {
                return "2015-06-30";
            } else {
                return year+ "-06-30";
            }
        } else {
            Integer year =  (1900 + today.getYear() - 1);
            if (year == 2016) {
                return "2015-06-30";
            } else {
                return year+ "-06-30";
            }
        }
    }

    /**
     * 获取现在时间属于那个年度
     * @param date
     * @return
     * @throws ParseException
     */
    public static String getNowYearByDate(String date) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date today = new Date();
        String todayString = simpleDateFormat.format(today);


        String startDateString = (1900 + today.getYear()) + "-06-30";
        Date startDate = simpleDateFormat.parse(startDateString);
        if (simpleDateFormat.parse(todayString).after(startDate)) {
            return (1900 + today.getYear()) + "";
        } else {
            return (1900 + today.getYear() - 1) + "";
        }
    }
    /**
     * 由于统计是每天晚上12点之后，所以获取现在时间要减一天才能获取属于那个年度
     * @param date
     * @return
     * @throws ParseException
     */
    public static String getNowYearByDateYeaterday(String date) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date today = simpleDateFormat.parse(date);
        String todayString = date;


        String startDateString = (1900 + today.getYear()) + "-06-30";
        Date startDate = simpleDateFormat.parse(startDateString);
        if (simpleDateFormat.parse(todayString).after(startDate)) {
            return (1900 + today.getYear()) + "";
        } else {
            return (1900 + today.getYear() - 1) + "";
        }
    }

    public static void main(String[] args) throws ParseException {
        System.out.println(getNowYearByDateYeaterday("2017-07-01"));
    }

    public static String getStartYear() throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date today = new Date();
        String todayString = simpleDateFormat.format(today);


        String startDateString = (1900 + today.getYear()) + "-07-01";
        Date startDate = simpleDateFormat.parse(startDateString);
        if (simpleDateFormat.parse(todayString).after(startDate)) {
            Integer year = (1900 + today.getYear());
            if (year == 2016) {
                return "2015-06-30";
            } else {
                return year+ "-06-30";
            }
        } else {
            Integer year =  (1900 + today.getYear() - 1);
            if (year == 2016) {
                return "2015-06-30";
            } else {
                return year+ "-06-30";
            }
        }
    }


    public static String getReason(String key) {
        switch (key) {
            case "1": {
                return level_sign_reason_1_name;
            }
            case "2": {
                return level_sign_reason_2_name;
            }
            case "3": {
                return level_sign_reason_3_name;
            }
            case "4": {
                return level_sign_reason_4_name;
            }
            case "5": {
                return level_sign_reason_5_name;
            }
            case "6": {
                return level_sign_reason_6_name;
            }
        }
        return "6";
    }

    public static String getServerType(String key) {
        switch (key) {
            case "1": {
                return "普通服务";
            }
            case "2": {
                return "老年人服务";
            }
            case "3": {
                return "慢性病服务";
            }
            case "4": {
                return "未知4";
            }
            case "5": {
                return "未知5";
            }
            case "6": {
                return "孕产妇";
            }
            case "7": {
                return "未知7";
            }
            case "8": {
                return "儿童（0-6岁）";
            }
            case "9": {
                return "高血压";
            }
            case "10": {
                return "糖尿病";
            }
            case "11": {
                return "贫困人口";
            }
            case "12": {
                return "计生特殊家庭";
            }
            case "13": {
                return "特殊人群";
            }
        }
        return "0";
    }


}
