package com.bcxin.ins.utils;


import com.bcxin.ins.core.service.ComDeployConfigService;
import com.bcxin.ins.spring.util.SpringContextHolder;
import com.bcxin.ins.util.ConstantUrl;
import com.bcxin.ins.util.GlobalResources;

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

/**
 * 通用配置数据库库缓存化
 */
public class ComDeployConfigUtils {



    private static ComDeployConfigService configService = SpringContextHolder.getBean(ComDeployConfigService.class);


    public static void setResource() {

        Map<String,String> map=configService.getAllConfig();
		GlobalResources.map=map;
        GlobalResources.PRODUCT_DETAIL_PATH=map.get("PRODUCT_DETAIL_PATH");//项目地址
		GlobalResources.DONOW_PATH=map.get("DONOW_PATH");//项目地址去掉请求头http://
		GlobalResources.WEB_URL=map.get("WEB_URL");//项目地址
		GlobalResources.BUSINESS_URL=map.get("BUSINESS_URL");
		GlobalResources.BASE_URL=map.get("BASE_URL");
		GlobalResources.DISTRIBUTION_IP=map.get("DISTRIBUTION_IP");//分销ip

		GlobalResources.DISTRIBUTION_LOGIN=map.get("DISTRIBUTION_LOGIN");//分销账号登录
		GlobalResources.WEB_PRO_URL=map.get("WEB_PRO_URL");
		GlobalResources.NEWS_PATH=map.get("NEWS_PATH");
		GlobalResources.COM_IMG_RE=map.get("COM_IMG_RE");
		GlobalResources.COM_IMG_LI=map.get("COM_IMG_LI");
		GlobalResources.CPIC_INS_URL=map.get("CPIC_INS_URL");
		GlobalResources.CPIC_GYX_URL=map.get("CPIC_GYX_URL");
		GlobalResources.SERVER_NAME=map.get("SERVER_NAME");
		GlobalResources.DIMENSIONCODE=map.get("DIMENSIONCODE");
		GlobalResources.POLICY_END_DAY=map.get("POLICY_END_DAY");

//		//oss
		GlobalResources.OSS_SERVERADDRESSS=map.get("OSS_SERVERADDRESSS");
		GlobalResources.OSS_IMG_SERVERADDRESSS=map.get("OSS_IMG_SERVERADDRESSS");
		GlobalResources.OSS_ACCESSID=map.get("OSS_ACCESSID");
		GlobalResources.OSS_ACCESSKEY=map.get("OSS_ACCESSKEY");
		GlobalResources.OSS_IMG_THUMBNAIL_CLASS=map.get("OSS_IMG_THUMBNAIL_CLASS");
		GlobalResources.OSS_IMG_AVERAGE_CLASS=map.get("OSS_IMG_AVERAGE_CLASS");
		GlobalResources.OSS_BUCKETNAME=map.get("OSS_BUCKETNAME");
		GlobalResources.HW_CDN_URL=map.get("HW_CDN_URL");
//

		GlobalResources.TOCORE_COM=map.get("TOCORE_COM");
		GlobalResources.TOCORE_POLICY=map.get("TOCORE_POLICY");
		GlobalResources.TOCORE_VERIFYNAME=map.get("TOCORE_VERIFYNAME");
		GlobalResources.ENVI_API=map.get("ENVI_API");
		GlobalResources.IS_CLOSE_NOTE=map.get("IS_CLOSE_NOTE");//是否关闭短信通道 1：是，0：否
		GlobalResources.IS_CLOSE_RECORD_SYNC=map.get("IS_CLOSE_RECORD_SYNC");//是否关闭批单同步业支 1：是，0：否
		GlobalResources.CONDITION=map.get("CONDITION");//当前环境：dev,test,env
		//泰康接口访问地址
		GlobalResources.TK_INS_URL=map.get("TK_INS_URL");
		//平安接口访问地址
		GlobalResources.PN_INS_URL=map.get("PN_INS_URL");
		//平安ibos上传附件接口访问地址
		GlobalResources.PN_IOBS_URL=map.get("PN_IOBS_URL");
		//平安收银台地址
		GlobalResources.PN_PAY_URL=map.get("PN_PAY_URL");
		//平安token代码
		GlobalResources.PN_ACCESS_TOKEN=map.get("PN_ACCESS_TOKEN");
		//平安寿获取tokenURL
		GlobalResources.PNS_GET_ACCESS_TOKEN_URL=map.get("PNS_GET_ACCESS_TOKEN_URL");
		//平安获取电子保单下载地址
		GlobalResources.PN_POLICY_FILE=map.get("PN_POLICY_FILE");
		//平安获取公钥
		GlobalResources.PN_POLICY_FILE_KEY=map.get("PN_POLICY_FILE_KEY");

		//平安获取tokenURL
		GlobalResources.PNC_GET_ACCESS_TOKEN_URL=map.get("PNC_GET_ACCESS_TOKEN_URL");

		//永安出单接口访问地址
		GlobalResources.YA_ZZ_INS_URL=map.get("YA_ZZ_INS_URL");
		GlobalResources.YA_ZZ_PWD=map.get("YA_ZZ_PWD");
		GlobalResources.YA_ZZ_OCODE=map.get("YA_ZZ_OCODE");

		//中华雇主投保接口访问地址
		GlobalResources.ZH_GZ_INS_URL=map.get("ZH_GZ_INS_URL");
		//中华雇主支付地址获取接口地址
		GlobalResources.ZH_GZ_PAY_URL=map.get("ZH_GZ_PAY_URL");
		//中华雇主申请发票获取接口地址
		GlobalResources.ZH_GZ_FP_URL=map.get("ZH_GZ_FP_URL");
		GlobalResources.GW_CH_PWD=map.get("GW_CH_PWD");

		//都邦核保接口访问地址
		GlobalResources.DB_INS_URL=map.get("DB_INS_URL");
		//都邦支付接口访问地址
		GlobalResources.DB_PAY_URL=map.get("DB_PAY_URL");
		//都邦接口访问服务器ip
		GlobalResources.DB_INS_IP=map.get("DB_INS_IP");
		//都邦电子保单下载地址头
		GlobalResources.DB_DOW_URL=map.get("DB_DOW_URL");
		//都邦秘钥key(测试：czVsBSUNe7gQK19n6diLiqgrTm4=，生产：TKlFg3ZslCEEZBwnHe1B2Hlzxc8=)
		GlobalResources.DB_INS_KEY=map.get("DB_INS_KEY");

		GlobalResources.CA_FP_API_URL=map.get("CA_FP_API_URL");
		//长安团意接口访问地址
		GlobalResources.CA_TY_API_URL=map.get("CA_TY_API_URL");
		GlobalResources.CA_TY_PAY_API_URL=map.get("CA_TY_PAY_API_URL");
		GlobalResources.CA_TY_PD_API_URL=map.get("CA_TY_PD_API_URL");
		GlobalResources.CA_TY_PD_2_API_URL=map.get("CA_TY_PD_2_API_URL");
		GlobalResources.CA_TY_BASL_API_URL=map.get("CA_TY_BASL_API_URL");
		GlobalResources.CA_TY_PRODUCT_CODE=map.get("CA_TY_PRODUCT_CODE");
		//太保雇主接口访问地址
		GlobalResources.TB_GZ_API_URL=map.get("TB_GZ_API_URL");
		GlobalResources.TB_GZ_SECRET_KEY=map.get("TB_GZ_SECRET_KEY");
		GlobalResources.TB_GZ_RECORD_WHITE=map.get("TB_GZ_RECORD_WHITE");
		//长安雇主接口访问地址
		GlobalResources.CA_GZ_API_URL=map.get("CA_GZ_API_URL");
		GlobalResources.CA_GZ_PAY_API_URL=map.get("CA_GZ_PAY_API_URL");
		GlobalResources.CA_GZ_PD_API_URL=map.get("CA_GZ_PD_API_URL");
		GlobalResources.CA_GZ_BASL_API_URL=map.get("CA_GZ_BASL_API_URL");
		//长安雇主证书信息
		GlobalResources.CA_GZ_KEY_STORE_PATH=map.get("CA_GZ_KEY_STORE_PATH");
		GlobalResources.CA_GZ_KEY_STORE_PASS=map.get("CA_GZ_KEY_STORE_PASS");
		GlobalResources.CA_GZ_TRUST_STORE_PATH=map.get("CA_GZ_TRUST_STORE_PATH");
		GlobalResources.CA_GZ_TRUST_STORE_PASS=map.get("CA_GZ_TRUST_STORE_PASS");

		/**  太保接口 107001  NO/YES */
		GlobalResources. IS_POLICY_TP107001_OPEN=map.get("IS_POLICY_TP107001_OPEN");
		/**  华泰 公责险 */
		GlobalResources.HT_INSUREPOLICYURL =map.get("HT_INSUREPOLICYURL");// 投保接口
		/**  众安 展责险 */
		GlobalResources.ZN_INS_URL =map.get("ZN_INS_URL");// 投保接口

		GlobalResources.HT_RECONCILIATIONURL =map.get("HT_RECONCILIATIONURL");//对账接口
		GlobalResources.HT_SURRENDERURL =map.get("HT_SURRENDERURL");//退保接口
		GlobalResources.HT_PAYADDRESS =map.get("HT_PAYADDRESS");//支付接口
		GlobalResources.HT_ENCRYPT_VAL =map.get("HT_ENCRYPT_VAL"); // MD5加密的值
		GlobalResources.HT_CHANNELCODE=map.get("HT_CHANNELCODE"); // 渠道编码
		GlobalResources.HT_PAYPAGECALLBACKADDRESS=map.get("HT_PAYPAGECALLBACKADDRESS");//同步返回的页面
		GlobalResources.HT_CALLBACKADDRESS=map.get("HT_CALLBACKADDRESS");//异步返回的页面
		GlobalResources.HT_SHOWURL=map.get("HT_SHOWURL");//商品展示链接
		GlobalResources.HT_SERVICES_URL=map.get("HT_SERVICES_URL");
		GlobalResources.HT_GZX_RSA_PRIVATEKEY=map.get("HT_GZX_RSA_PRIVATEKEY");
		GlobalResources.HT_GZX_RSA_PUBLICKEY=map.get("HT_GZX_RSA_PUBLICKEY");
		GlobalResources.HT_TYX_CHANNELCODE=map.get("HT_TYX_CHANNELCODE");
		GlobalResources.HT_TYX_RSA_PRIVATEKEY=map.get("HT_TYX_RSA_PRIVATEKEY");
		GlobalResources.HT_TYX_RSA_PUBLICKEY=map.get("HT_TYX_RSA_PUBLICKEY");
		GlobalResources.P_SERVICES_URL=map.get("P_SERVICES_URL");
		GlobalResources.WEB_PRO_URL=map.get("WEB_PRO_URL");
		GlobalResources.ESTAND_XCX_QR_CODE=map.get("ESTAND_XCX_QR_CODE");
		//环境参数
		GlobalResources.IS_TEST_ENVI="NO".equals(GlobalResources.ENVI_API)?true:false;
		GlobalResources.IS_WINDOWS_ENVI="NO".equals(GlobalResources.ENVI_API)?true:false;
    }

    public static void setUrl() {
		Map<String,String >	mapUrl= new HashMap<String ,String >();
		mapUrl.put(ConstantUrl.INDEX_URL,GlobalResources.WEB_PRO_URL);
		mapUrl.put(ConstantUrl.PRODUCT_TYPE_URL,GlobalResources.WEB_PRO_URL+"");
		GlobalResources.map=mapUrl;
    }
}
