package com.dxhy.common.util;

/**
 * 根据发票代码获取所属省份信息
 *
 * @author Administrator
 *
 */
@SuppressWarnings({"AlibabaUndefineMagicConstant", "AlibabaMethodTooLong"})
public class AreaUtil {

    private String dqdm = "";

    private String dqmc = "";

    private String sfdm = "";

    public String getDqdm() {
        return dqdm;
    }

    public void setDqdm(String dqdm) {
        this.dqdm = dqdm;
    }

    public String getDqmc() {
        return dqmc;
    }

    public void setDqmc(String dqmc) {
        this.dqmc = dqmc;
    }

    public String getSfdm() {
        return sfdm;
    }

    public void setSfdm(String sfdm) {
        this.sfdm = sfdm;
    }

    public AreaUtil() {
        if (StringHelper.isBlank(dqdm)) {
            this.getDqxx();
        }
    }

    public AreaUtil(String fpdm) {
        if (fpdm != null) {
            if (fpdm.length() == 10) {
                dqdm = fpdm.substring(0, 4);
                this.getDqxx();
            } else if (fpdm.length() == 12) {
                dqdm = fpdm.substring(1, 5);
                this.getDqxx();
            } else {
                dqdm = null;
                dqmc = null;
                sfdm = null;
            }
        }
    }

    private void getDqxx() {

        if (dqdm != null && dqdm.length() > 0) {
            if (dqdm.length() == 4) {
                if (!"2102,3302,3702,3502,4403".contains(dqdm)) {
                    dqdm = dqdm.substring(0, 2) + "00";
                }
                switch (dqdm) {
                    case "1100":
                        sfdm = "111000000";
                        dqmc = "北京";
                        break;
                    case "1200":
                        sfdm = "112000000";
                        dqmc = "天津";
                        break;
                    case "1300":
                        sfdm = "113000000";
                        dqmc = "河北";
                        break;
                    case "1400":
                        sfdm = "114000000";
                        dqmc = "山西";
                        break;
                    case "1500":
                        sfdm = "115000000";
                        dqmc = "内蒙古";
                        break;
                    case "2100":
                        sfdm = "121000000";
                        dqmc = "辽宁";
                        break;
                    case "2102":
                        sfdm = "121020000";
                        dqmc = "大连";
                        break;
                    case "2200":
                        sfdm = "122000000";
                        dqmc = "吉林";
                        break;
                    case "2300":
                        sfdm = "123000000";
                        dqmc = "黑龙江";
                        break;
                    case "3100":
                        sfdm = "131000000";
                        dqmc = "上海";
                        break;
                    case "3200":
                        sfdm = "132000000";
                        dqmc = "江苏";
                        break;
                    case "3300":
                        sfdm = "133000000";
                        dqmc = "浙江";
                        break;
                    case "3302":
                        sfdm = "133020000";
                        dqmc = "宁波";
                        break;
                    case "3400":
                        sfdm = "134000000";
                        dqmc = "安徽";
                        break;
                    case "3500":
                        sfdm = "135000000";
                        dqmc = "福建";
                        break;
                    case "3502":
                        sfdm = "135020000";
                        dqmc = "厦门";
                        break;
                    case "3600":
                        sfdm = "136000000";
                        dqmc = "江西";
                        break;
                    case "3700":
                        sfdm = "137000000";
                        dqmc = "山东";
                        break;
                    case "3702":
                        sfdm = "137020000";
                        dqmc = "青岛";
                        break;
                    case "4100":
                        sfdm = "141000000";
                        dqmc = "河南";
                        break;
                    case "4200":
                        sfdm = "142000000";
                        dqmc = "湖北";
                        break;
                    case "4300":
                        sfdm = "143000000";
                        dqmc = "湖南";
                        break;
                    case "4400":
                        sfdm = "144000000";
                        dqmc = "广东";
                        break;
                    case "4403":
                        sfdm = "144030000";
                        dqmc = "深圳";
                        break;
                    case "4500":
                        sfdm = "145000000";
                        dqmc = "广西";
                        break;
                    case "4600":
                        sfdm = "146000000";
                        dqmc = "海南";
                        break;
                    case "5000":
                        sfdm = "150000000";
                        dqmc = "重庆";
                        break;
                    case "5100":
                        sfdm = "151000000";
                        dqmc = "四川";
                        break;
                    case "5200":
                        sfdm = "152000000";
                        dqmc = "贵州";
                        break;
                    case "5300":
                        sfdm = "153000000";
                        dqmc = "云南";
                        break;
                    case "5400":
                        sfdm = "154000000";
                        dqmc = "西藏";
                        break;
                    case "6100":
                        sfdm = "161000000";
                        dqmc = "陕西";
                        break;
                    case "6200":
                        sfdm = "162000000";
                        dqmc = "甘肃";
                        break;
                    case "6300":
                        sfdm = "163000000";
                        dqmc = "青海";
                        break;
                    case "6400":
                        sfdm = "164000000";
                        dqmc = "宁夏";
                        break;
                    case "6500":
                        sfdm = "165000000";
                        dqmc = "新疆";
                        break;
                    default:
                        break;
                }
            }
        }
    }

}
