package com.chinaweal.aiccs.common.util;

import com.chinaweal.aiccs.common.constant.Constant;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Class: 常量工具类
 * User: zhouls
 * Date: 14-5-14
 * Time: 上午10:19
 * To change this template use File | Settings | File Templates.
 */
public class ConstantsUtil {
    //当前登录用户实体标识
    public static final String USER_SESSION_NAME = "AICUSER";


    private static Map<String, String> ABNORMALLIST_INDIVIDUAL_TAG = new HashMap<String, String>();//个体户列入原因
    private static Map<String, String> ABNORMALLIST_ENTER_ADD = new HashMap<String, String>();//企业列入
    private static Map<String, String> SERILLEGAL_ENTER_ADD = new HashMap<String, String>();//严重违法失信列入
    private static Map<String, String> ABNORMALLIST_FARMER_ADD = new HashMap<String, String>();//异常名录列入原因
    private static Map<String, String> QUALIFICATION_ENTER_STATUS = new HashMap<String, String>();//年报企业状态
    private static Map<String, String> ENTWEB_WEBTYPE = new HashMap<String, String>();//企业年报查询网店或网站类型
    private static Map<String, String> SHOW_NOSHOW_MAP = new HashMap<String, String>();//公示不公示

    private static Map<String, String> RANDOMDEVICE_MAP = new HashMap<String, String>();//随机策略

    private static Map<String,String>  CHECKEDSUG_MAP=new HashMap<String, String>();//检查人员意见和建议

    private static Map<String,String>  SUEINSPECT_INSPECTTYPE_MAP = new HashMap<>();//应诉检查检查方式
    private static Map<String,String>  SUEINSPECT_INSPECTRESULT_MAP = new HashMap<>();//应诉检查检查结果

    public static final String ABNORMALLIST_TYPE_SPECAUSE_ONE = "1";
    public static final String ABNORMALLIST_TYPE_SPECAUSE_TWO = "2";
    public static final String ABNORMALLIST_TYPE_SPECAUSE_THREE = "3";
    public static final String ABNORMALLIST_TYPE_SPECAUSE_FOUR = "4";

    public static final String SERILLEGAL_TYPE_SERILLREA_ONE = "1";
    public static final String SERILLEGAL_TYPE_SERILLREA_TWO = "2";
    public static final String SERILLEGAL_TYPE_SERILLREA_THREE = "3";

    public final static String QUALIFICATION_OPEN = "1";  //在营（开业）企业
    public final static String QUALIFICATION_REVOKE = "2";  //吊销企业
    public final static String QUALIFICATION_CANCEL = "3";  //注销企业
    public final static String QUALIFICATION_MOVEOUT = "4";  //迁出
    public final static String QUALIFICATION_GOTOVOKE = "5";  //撤销
    public final static String QUALIFICATION_STOP = "8";  //停业
    public final static String QUALIFICATION_OTHER = "9";  //其他

    public final static String  ENTWEB_WEBTYPE_WEBSITE="1";//网站
    public final static String  ENTWEB_WEBTYPE_STORE="2";//网店     、

    public final static String  SHOW_NOSHOW_MAP_NOSHOW="0";//不公示
    public final static String  SHOW_NOSHOW_MAP_SHOW="1";//公示
    public final static String  SHOW_NOSHOW_MAP_NOSHOWCOPY="2";//不公示

    public final static String  RANDOMDEVICE_ALL ="0";//全局随机
    public final static String  RANDOMDEVICE_AREA="1";//片区随机
    public final static String  RANDOMDEVICE_ORG="2";//所内随机

    public final static String CHECKEDSUG_ONE="1";
    public final static String CHECKEDSUG_TOW="2";
    public final static String CHECKEDSUG_THREE="3";
    public final static String CHECKEDSUG_FOUR="4";

    // 批量未年报列异Redis标识
    public final static String BATCH_NB_REDIS_KEY = "batch_nb_redis_key:";

    // 浪潮门户access_token缓存标识
    public final static String LANG_CHAO_ACCESS_TOKEN_KEY = "lang_chao_access_token:";

    static {
        ABNORMALLIST_INDIVIDUAL_TAG.put(ABNORMALLIST_TYPE_SPECAUSE_ONE, "未按规定报送年度报告");
        ABNORMALLIST_INDIVIDUAL_TAG.put(ABNORMALLIST_TYPE_SPECAUSE_TWO, "年度报告隐瞒真实情况、弄虚作假");
        ABNORMALLIST_INDIVIDUAL_TAG.put(ABNORMALLIST_TYPE_SPECAUSE_THREE, "通过登记的经营场所或者经营者住所无法取得联系");
        ABNORMALLIST_INDIVIDUAL_TAG = Collections.unmodifiableMap(ABNORMALLIST_INDIVIDUAL_TAG);

        ABNORMALLIST_ENTER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_ONE, "未依照规定限期公示年度报告");
        ABNORMALLIST_ENTER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_TWO, "未依照规定责令的期限内公示有关企业信息");
        ABNORMALLIST_ENTER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_THREE, "公示企业信息隐瞒真实情况、弄虚作假的");
        ABNORMALLIST_ENTER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_FOUR, "通过登记的住所或经营场所无法联系的");
        ABNORMALLIST_ENTER_ADD = Collections.unmodifiableMap(ABNORMALLIST_ENTER_ADD);

        SERILLEGAL_ENTER_ADD.put(SERILLEGAL_TYPE_SERILLREA_ONE, "经营异常名录期限届满");
        SERILLEGAL_ENTER_ADD.put(SERILLEGAL_TYPE_SERILLREA_TWO, "存在严重违法失信行为");
        SERILLEGAL_ENTER_ADD.put(SERILLEGAL_TYPE_SERILLREA_THREE, "协助执行");
        SERILLEGAL_ENTER_ADD = Collections.unmodifiableMap(SERILLEGAL_ENTER_ADD);

        ABNORMALLIST_FARMER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_ONE, "农民专业合作社未按照《农民专业合作社年度报告公示办法》规定报送年度报告并公示的");
        ABNORMALLIST_FARMER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_TWO, "农民专业合作社年度报告信息隐瞒真实情况、弄虚作假的");
        ABNORMALLIST_FARMER_ADD.put(ABNORMALLIST_TYPE_SPECAUSE_THREE, "工商行政管理部门在依法履职过程中通过登记的住所无法与农民专业合作社取得联系的");
        ABNORMALLIST_FARMER_ADD = Collections.unmodifiableMap(ABNORMALLIST_FARMER_ADD);

        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_OPEN,"在营（开业）企业 ");
        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_REVOKE,"吊销企业");
        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_CANCEL,"注销企业");
        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_MOVEOUT,"迁出");
        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_GOTOVOKE,"撤销");
        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_STOP,"停业");
        QUALIFICATION_ENTER_STATUS.put(QUALIFICATION_OTHER,"其他");
        QUALIFICATION_ENTER_STATUS=Collections.unmodifiableMap(QUALIFICATION_ENTER_STATUS);

        ENTWEB_WEBTYPE.put(ENTWEB_WEBTYPE_WEBSITE,"网站");
        ENTWEB_WEBTYPE.put(ENTWEB_WEBTYPE_STORE,"网店");
        ENTWEB_WEBTYPE= Collections.unmodifiableMap(ENTWEB_WEBTYPE);

        SHOW_NOSHOW_MAP.put(SHOW_NOSHOW_MAP_NOSHOW,"不公示");
        SHOW_NOSHOW_MAP.put(SHOW_NOSHOW_MAP_SHOW,"公示");
        SHOW_NOSHOW_MAP.put(SHOW_NOSHOW_MAP_NOSHOWCOPY,"不公示");
        SHOW_NOSHOW_MAP=Collections.unmodifiableMap(SHOW_NOSHOW_MAP);

        RANDOMDEVICE_MAP.put(RANDOMDEVICE_ALL, "全局随机");
        RANDOMDEVICE_MAP.put(RANDOMDEVICE_AREA, "片区随机");
        RANDOMDEVICE_MAP.put(RANDOMDEVICE_ORG, "所内随机");

        CHECKEDSUG_MAP.put(CHECKEDSUG_ONE, "（一）拒绝检查人员或其委托的专业机构进入被检查场所的");
        CHECKEDSUG_MAP.put(CHECKEDSUG_TOW, "（二）拒绝向检查人员或其委托的专业机构提供相关材料的");
        CHECKEDSUG_MAP.put(CHECKEDSUG_THREE, "（三）不如实或不按要求提供情况或相关材料的");
        CHECKEDSUG_MAP.put(CHECKEDSUG_FOUR, "（四）其他阻挠、妨碍抽查工作的行为，致使抽查工作无法正常进行的");

        SUEINSPECT_INSPECTTYPE_MAP.put("1","书面检查");
        SUEINSPECT_INSPECTTYPE_MAP.put("2","实地核查");
        SUEINSPECT_INSPECTTYPE_MAP.put("3","网络监测");
        SUEINSPECT_INSPECTTYPE_MAP.put("4","委托专业机构开展检查");

        SUEINSPECT_INSPECTRESULT_MAP.put("1","未发现问题");
        SUEINSPECT_INSPECTRESULT_MAP.put("2","未按规定公示应当公示的信息");
        SUEINSPECT_INSPECTRESULT_MAP.put("3","公示信息隐瞒真实情况弄虚作假");
        SUEINSPECT_INSPECTRESULT_MAP.put("4","通过登记住所（经营场所）无法联系");
        SUEINSPECT_INSPECTRESULT_MAP.put("5","发现问题已责令改正");
        SUEINSPECT_INSPECTRESULT_MAP.put("6","不配合检查情节严重");
        SUEINSPECT_INSPECTRESULT_MAP.put("7","未发现开展本次检查涉及的经营活动");
        SUEINSPECT_INSPECTRESULT_MAP.put("8","发现问题待后续处理");

    }

    public static Map<String, String> getAbnormallistIndividualTag() {
        return ABNORMALLIST_INDIVIDUAL_TAG;
    }

    public static Map<String, String> getAbnormallistEnterAdd() {
        return ABNORMALLIST_ENTER_ADD;
    }

    public static Map<String, String> getSerillegalEnterAdd() {
        return SERILLEGAL_ENTER_ADD;
    }

    public static Map<String, String> getAbnormallistFarmerAdd() {
        return ABNORMALLIST_FARMER_ADD;
    }
    public static Map<String, String> getQualification() {
        return QUALIFICATION_ENTER_STATUS;
    }
    public static Map<String, String> getEntWebWebtype() {
        return ENTWEB_WEBTYPE;
    }
    public static Map<String, String> getShowNoshow() {
        return SHOW_NOSHOW_MAP;
    }
    public static Map<String, String> getRandomDeviceMap() {
        return RANDOMDEVICE_MAP;
    }
    public static Map<String, String> getCheckedsugMap() {
        return CHECKEDSUG_MAP;
    }
    public static Map<String, String> getInspectTypeMap() {
        return SUEINSPECT_INSPECTTYPE_MAP;
    }
    public static Map<String, String> getInspectResultMap() {
        return SUEINSPECT_INSPECTRESULT_MAP;
    }

//    /**
//     * 根据地区码值获取简称
//     * @param areaCode 地区码值
//     * @return 找不到对应的则返回null
//     */
//    public static String getAreaShortName(String areaCode){
//        Map<String, String> map = Constant.NM_REGION_CODE_SHORTNAME;
//        String shortName = "穗";
//        boolean flag = false;
//        for (String code : map.keySet()) {
//            if(code.equals(areaCode)){
//                if(!map.get(code).equals("穗")){//区的在前面补上穗
//                    shortName += map.get(code);
//                }
//                flag = true;
//                break;
//            }
//        }
//        if(flag){
//            return shortName;
//        }else {
//            return null;
//        }
//    }
    /**
     * 根据地区码值获取地区名称
     * @param areaCode 地区码值
     * @return 找不到对应的则返回null
     */
    public static String getAreaName(String areaCode){
        Map<String, String> map = Constant.NM_LOC_REGION_CODE;
        String name = "";
        boolean flag = false;
        for (String code : map.keySet()) {
            if(code.equals(areaCode)){
                if(!map.get(code).equals(name)){//区的在前面补上市
                    name += map.get(code);
                }
                flag = true;
                break;
            }
        }
        if(flag){
            return name;
        }else {
            return null;
        }
    }

//    public static String getAddr(String areaCode){
//        Map<String, String> map = Constant.GZ_XZFY_LJ;
//        boolean flag = false;
//        String addr = "";
//        for (String code : map.keySet()) {
//            if(code.equals(areaCode)){
//                addr = map.get(code);
//                flag = true;
//                break;
//            }
//        }
//        if(flag){
//            return addr;
//        }else {
//            return null;
//        }
//    }
//
//    public static String getPhone(String areaCode){
//        Map<String, String> map = Constant.GZ_XZFY_DH;
//        boolean flag = false;
//        String phoneDW = "";
//        for (String code : map.keySet()) {
//            if(code.equals(areaCode)){
//                phoneDW = map.get(code);
//                flag = true;
//                break;
//            }
//        }
//        if(flag){
//            return phoneDW;
//        }else {
//            return null;
//        }
//    }
//
//    public static String getlyAddr(String areaCode){
//        Map<String, String> map = Constant.GZ_LY_DZ;
//        return map.get(areaCode);
//    }
//
//    public static String getlyPhone(String areaCode){
//        Map<String, String> map = Constant.GZ_LY_DH;
//        return map.get(areaCode);
//    }
//
//    public static String getTFbmcode(String orgUnitName){
//        Map<String, String> map = Constant.TF_BMDMZ;
//        boolean flag = false;
//        String code = "";
//        for (String name : map.keySet()) {
//            if(name.equals(orgUnitName)){
//                code = map.get(name);
//                flag = true;
//                break;
//            }
//        }
//        if(flag){
//            return code;
//        }else {
//            return null;
//        }
//    }

    /**
     * 根据地区码值获取决定机关名称
     * @param areaCode 地区码值
     * @return 找不到对应的则返回null
     */
    public static String getDecOrgName(String areaCode){
        String areaName = getAreaName(areaCode);
        if(areaName != null) {
            areaName = areaName +"市场监督管理局";
        }
        return areaName;
    }
    /**
     * 根据机关名称获取机关码值
     * @param areaName 机关名称
     * @return 找不到对应的则返回null
     */
    public static String getAreaNameCode(String areaName) {
        Map<String, String> map = Constant.NM_DECORG_CODE;
        for (Map.Entry<String, String> entry : map.entrySet()) {
            if (areaName.contains(entry.getValue())) {
                return entry.getKey();
            }
        }
        return "15000000";// 暂定找不到的默认为内蒙
    }

    /**
     * 两套机关码值映射关系
     * @param code  机关码值
     * @return
     */
    public static String[] getDecOrgList(String code){
        if(code == null) return null;
        switch (code){
            case "440101":
                return new String[]{"440100", "440101"};
            case "440125":
                return new String[]{"440125", "440118"};
            case "440122":
                return new String[]{"440122", "440117"};
            case "440121":
                return new String[]{"440121", "440114"};
            default:
                return new String[]{code};
        }
    }

    /**
     * 企业状态标准值映射
     * @param regState  码值
     * @return
     */
    public static String getRegStateCn(String regState){
        String regStateCn = null;
        //根据国标CA19 经营状态代码返回
        if ("1".equals(regState)) {
            return "存续（在营、开业、在册）";
        } else if ("2".equals(regState)) {
            return "吊销，未注销";
        } else if ("3".equals(regState)) {
            return "吊销，已注销";
        } else if ("4".equals(regState)) {
            return "注销";
        } else if ("5".equals(regState)) {
            return "撤销";
        } else if ("6".equals(regState)) {
            return "迁出";
        } else if ("9".equals(regState)) {
            return "其他";
        }
        return regStateCn;
    }

    /**
     * 根据企业类型获取individual  farmer company
     * @author ymc
     * @since 2024年9月13日 10:32
     * @param entType
     * @return
     */
    public static String getEntTypeAlias(String entType) {
        if (entType == null) return "company";
        return entType.equals("9100") || entType.equals("9200") ? "farmer" : entType.equals("9910") ? "individual" : "company";
    }
}
