package com.chinaweal.aiccs.common.util;

import com.chinaweal.youfool.framework.springboot.exception.custom.BusinessException;

import java.util.HashMap;
import java.util.Map;

/**
 * 文号常量
 * Created by xiaot on 2017/6/29.
 */

public class WorkNoUtil {

    private static final Map<String, String> WorkNoType_MAP = new HashMap<String, String>();

    //信用修复-严重违法
    public static final String SER_WORKNOTYPE_1 ="1";  //	信用修复申请书
    public static final String SER_WORKNOTYPE_2 ="2";  //	守信承诺书
    public static final String SER_WORKNOTYPE_3 ="3";  //	履行法定义务、纠正违法行为的相关材料
    public static final String SER_WORKNOTYPE_6 ="6";  //	信用修复授权委托书
    public static final String SER_WORKNOTYPE_8 ="8";  //	法人身份证信息
    public static final String SER_WORKNOTYPE_7 ="7";  //	营业执照照片
    public static final String SER_WORKNOTYPE_4 ="4";  //	其他材料

    //信用修复-经营异常
    public static final String ABN_WORKNOTYPE_1 ="1";  //	《信用修复申请书》
    public static final String ABN_WORKNOTYPE_8 ="8";  //	《信用修复承诺书》
    public static final String ABN_WORKNOTYPE_7 ="7";  //	履行法定义务、纠正违法行为的相关材料-年度报告
    public static final String ABN_WORKNOTYPE_9 ="9";  //	履行法定义务、纠正违法行为的相关材料-弄虚作假
    public static final String ABN_WORKNOTYPE_2 ="2";  //	履行法定义务、纠正违法行为的相关材料-注册地址
    public static final String ABN_WORKNOTYPE_3 ="3";  //	《信用修复授权委托书》
    public static final String ABN_WORKNOTYPE_88 ="88";  //	法人身份证信息
    public static final String ABN_WORKNOTYPE_4 ="4";  //	营业执照照片
    public static final String ABN_WORKNOTYPE_99 ="99";  //	其他材料

    public static final String WORKNOTYPE_01 ="01";  //	监检
    public static final String WORKNOTYPE_02 ="02";  //	检通
    public static final String WORKNOTYPE_03 ="03";  //	责改
    public static final String WORKNOTYPE_11 ="11";  //	企业列入经营异常名录决定书文号
    public static final String WORKNOTYPE_12 ="12";  //	列入经营异常名录异议受理通知书
    public static final String WORKNOTYPE_13 ="13";	//  列入经营异常名录异议不予受理通知书
    public static final String WORKNOTYPE_14 ="14";  //	列入经营异常名录异议核实结果告知书
    public static final String WORKNOTYPE_15 ="15";  //	移出经营异常名录决定书

    public static final String WORKNOTYPE_17 ="17";  //	未年报被列入公示--内蒙古自治区市场监督管理局列入经营异常名录决定书

    public static final String WORKNOTYPE_16 ="16";  //	拍卖前备案文号

    public static final String WORKNOTYPE_20 ="20";  //	拟列入严重违法失信名单 决定书文号
    public static final String WORKNOTYPE_21 ="21";  //	列入严重违法失信名单 决定书文号
    public static final String WORKNOTYPE_22 ="22";  //	列入严重违法失信名单 异议受理通知书
    public static final String WORKNOTYPE_23 ="23";	//  列入严重违法失信名单 异议不予受理通知书
    public static final String WORKNOTYPE_24 ="24";  //	列入严重违法失信名单 异议核实结果告知书
    public static final String WORKNOTYPE_25 ="25";  //	移出严重违法失信名单 决定书
    public static final String WORKNOTYPE_26 ="26";  //	移出严重违法失信名单 受理申请回执单


    public static final String WORKNOTYPE_31 ="31";  // 批量吊销案件终结报告书
    public static final String WORKNOTYPE_32 ="32";  //	批量吊销听证告知书
    public static final String WORKNOTYPE_33 ="33";  //	批量吊销行政处罚决定书
    public static final String WORKNOTYPE_34 ="34"; // 批吊撤销决定书
    public static final String WORKNOTYPE_35 ="35"; // 批吊复议决定书
    public static final String WORKNOTYPE_36 ="36"; // 批吊诉讼决定书

    public static final String WORKNOTYPE_41 ="41";  // 冒用他人身份撤销登记决定书
    public static final String WORKNOTYPE_42 ="42";  // 撤销登记案件现场核查通知书
    public static final String WORKNOTYPE_43 ="43";  // 批量撤销登记听证文书
    public static final String WORKNOTYPE_44 ="44";  // 批量撤销设立登记决定书

    public static final String WORKNOTYPE_51 ="51";  // 信用修复不予受理决定书
    public static final String WORKNOTYPE_52 ="52";  // 严重违法-不予信用修复决定书
    public static final String WORKNOTYPE_53 ="53";  // 严重违法-准予信用修复决定书
    public static final String WORKNOTYPE_54 ="54";  // 严重违法-不予信用修复决定书--无印章版
    public static final String WORKNOTYPE_55 ="55";  // 企业农专-不予信用修复决定书
    public static final String WORKNOTYPE_56 ="56";  // 企业农专-准予信用修复决定书
    public static final String WORKNOTYPE_57 ="57";  // 企业农专-不予信用修复决定书--无印章版
    public static final String WORKNOTYPE_58 ="58";  // 个体户-不予信用修复决定书
    public static final String WORKNOTYPE_59 ="59";  // 个体户-准予信用修复决定书
    public static final String WORKNOTYPE_60 ="60";  // 个体户-不予信用修复决定书--无印章版
    public static final String WORKNOTYPE_61 ="61";  // 严重违法-准予信用修复决定书--无印章版
    public static final String WORKNOTYPE_62 ="62";  // 企业农专-准予信用修复决定书--无印章版
    public static final String WORKNOTYPE_63 ="63";  // 个体户-准予信用修复决定书--无印章版
    public static final String WORKNOTYPE_64 ="64";  // 批量注销公告书
    public static final String WORKNOTYPE_65 ="65";  // 行政处罚修复-准予信用修复决定书
    public static final String WORKNOTYPE_66 ="66";  // 行政处罚修复-不予信用修复决定书

    public static final String WORKNOTYPE_71 = "71";  // 拟强制注销公司登记公告
    public static final String WORKNOTYPE_72 = "72";  // 强制注销公司登记决定书
    public static final String WORKNOTYPE_73 = "73";  // 强制注销公司登记决定送达公告
    public static final String WORKNOTYPE_74 = "74";  // 强制注销公司登记营业执照作废公告
    public static final String WORKNOTYPE_75 = "75";  // 强制注销公司恢复登记决定书
    public static final String WORKNOTYPE_76 = "76";  // 强制注销公司不予恢复登记告知书

    public static final String WORKNOTYPE_80 = "80";  // 其他部门列入严重违法失信企业名单（黑名单）
    public static final String WORKNOTYPE_81 = "81";  // 其他部门移出严重违法失信企业名单（黑名单）


    /**
     * 文书类型-文书号规则集合
     */
    private static final Map<String, String> WRITSNO_GENRULE_MAP = new HashMap<String, String>();
    private static final Map<String, String> CITY = new HashMap<>();

    static {
        WorkNoType_MAP.put(WORKNOTYPE_01, "监检");
        WorkNoType_MAP.put(WORKNOTYPE_02, "检通");
        WorkNoType_MAP.put(WORKNOTYPE_03, "责改");
        WorkNoType_MAP.put(WORKNOTYPE_11, "企业列入经营异常名录决定书文号");
        WorkNoType_MAP.put(WORKNOTYPE_12, "列入经营异常名录异议受理通知书");
        WorkNoType_MAP.put(WORKNOTYPE_13, "列入经营异常名录异议不予受理通知书");
        WorkNoType_MAP.put(WORKNOTYPE_14, "列入经营异常名录异议核实结果告知书");
        WorkNoType_MAP.put(WORKNOTYPE_15, "移出经营异常名录决定书");


        WorkNoType_MAP.put(WORKNOTYPE_16, "拍卖前备案文号");


        WorkNoType_MAP.put(WORKNOTYPE_20, "拟列入严重违法失信名单决定书");
        WorkNoType_MAP.put(WORKNOTYPE_21, "列入严重违法失信名单决定书文书");
        WorkNoType_MAP.put(WORKNOTYPE_22, "列入严重违法失信名单异议受理通知书");
        WorkNoType_MAP.put(WORKNOTYPE_23, "列入严重违法失信名单异议不予受理通知书");
        WorkNoType_MAP.put(WORKNOTYPE_24, "列入严重违法失信名单异议核实结果告知书");
        WorkNoType_MAP.put(WORKNOTYPE_25, "移出严重违法失信名单决定书");
        WorkNoType_MAP.put(WORKNOTYPE_26, "移出严重违法失信名单受理申请回执单");


        WorkNoType_MAP.put(WORKNOTYPE_31, "吊销案件终结报告书");
        WorkNoType_MAP.put(WORKNOTYPE_32, "吊销听证告知书");
        WorkNoType_MAP.put(WORKNOTYPE_33, "吊销行政处罚决定书");


        WorkNoType_MAP.put(WORKNOTYPE_51, "信用修复不予受理决定书");
        WorkNoType_MAP.put(WORKNOTYPE_52, "严重违法不予信用修复决定书");
        WorkNoType_MAP.put(WORKNOTYPE_53, "严重违法准予信用修复决定书");
        WorkNoType_MAP.put(WORKNOTYPE_54, "严重违法准予信用修复决定书无印章版");
        WorkNoType_MAP.put(WORKNOTYPE_43, "批量撤销登记听证告知书");
        WorkNoType_MAP.put(WORKNOTYPE_44, "批量撤销设立登记决定书");
        WorkNoType_MAP.put(WORKNOTYPE_64, "批量注销登记公告");

        WorkNoType_MAP.put(WORKNOTYPE_65, "行政处罚修复公告");

        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_11,"{ShortName}市监列异[{year}]第{CurrentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_12,"{ShortName}市监异议受理通字[{year}]第{CurrentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_13,"{ShortName}市监异议不受通字[{year}]第{CurrentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_14,"{ShortName}市监异议核实告字[{year}]第{CurrentNo}号");

        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_20,"{shortName}市监提列严字[{year}]第{currentNo}号");

        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_43,"{shortName}市监撤销听证字[{year}]第{currentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_44,"{shortName}市监撤销字[{year}]第{currentNo}号");

        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_71, "{shortName}市监拟强注决字[{year}]第{currentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_72, "{shortName}市监强注决字[{year}]第{currentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_75, "{shortName}市监恢复决字[{year}]第{currentNo}号");
        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_76, "{shortName}市监不予恢复决字[{year}]第{currentNo}号");

        WRITSNO_GENRULE_MAP.put(WORKNOTYPE_65, "{ShortName}市监信修字[{year}]第{CurrentNo}号");
    }

    public static String getWorkNoTypeName(String workNoType) {
        return  WorkNoType_MAP.get(workNoType);
    }

    public static String getWorkNoGenrule(String workNoType) {
        return  WRITSNO_GENRULE_MAP.get(workNoType);
    }

    /**
     * 获取区域名称
     * @param areaCode 区域编号
     * @return
     */
    public static String getCityByAreaCode(String areaCode) {
        if (StringUtils.isBlank(areaCode)) {
            throw new BusinessException("传入orgNumber为空，获取区域名称失败");
        }
        if (areaCode.length() < 4) {
            throw new BusinessException("机构号长度不足4位");
        }
        String cityName = CITY.get(areaCode.substring(0, 4));
        if (cityName == null) {
            throw new BusinessException("获取区域名称失败，orgNumber：" + areaCode);
        }
        return cityName;
    }

}
