/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  javax.servlet.ServletContext
 *  javax.servlet.http.HttpServlet
 *  org.apache.commons.logging.Log
 *  org.apache.commons.logging.LogFactory
 *  org.dom4j.Document
 *  org.dom4j.DocumentException
 *  org.dom4j.Element
 *  org.dom4j.io.SAXReader
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.orm.ibatis.SqlMapClientTemplate
 *  org.springframework.stereotype.Service
 *  org.springframework.web.context.WebApplicationContext
 *  org.springframework.web.context.support.WebApplicationContextUtils
 */
package com.hst.framework.util;

import com.hst.framework.constants.WebConstants;
import com.hst.framework.domain.JhxtXtcsDomain;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

@Service
public class HstInitUtil
extends HttpServlet {
    private static final long serialVersionUID = 3574019451372146643L;
    public static Log _logger = LogFactory.getLog(HstInitUtil.class);
    @Autowired
    private SqlMapClientTemplate smzbsSqlMapClientTemplate;

    public void init() {
        WebApplicationContext webApplicationContext;
        ServletContext servletContext = this.getServletContext();
        WebConstants.WEB_APP_CONTEXT = webApplicationContext = WebApplicationContextUtils.getWebApplicationContext((ServletContext)servletContext);
        this.smzbsSqlMapClientTemplate = (SqlMapClientTemplate)webApplicationContext.getBean("smzbsSqlMapClientTemplate");
        this.initWebConstants();
        this.initHstConfig();
        this.initZfpzConfig();
        this.initForwardConfig();
        if ("Y".equals(WebConstants.SMZ_RXBD_JK_GT3)) {
            try {
                this.initSmzbsBsdtDjxh();
                this.initQhbzPz();
                this.initJhxtXtcs();
                _logger.info((Object)"smbd:!\u63d0\u524d\u521d\u59cb\u5316\u5b9e\u540d\u6bd4\u5bf9\u63a5\u53e3");
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void initHstConfig() {
    }

    /*
     * WARNING - void declaration
     */
    private void initWebConstants() {
        Properties pro = new Properties();
        try {
            void var4_7;
            pro.load(((Object)((Object)this)).getClass().getResourceAsStream("/config/hst.properties"));
            HashMap<String, String> hstPropMap = new HashMap<String, String>();
            for (String string : pro.keySet()) {
                hstPropMap.put(string, pro.getProperty(string, ""));
            }
            WebConstants.HST_PROP_MAP = hstPropMap;
            WebConstants.SES_USER_INFO = pro.getProperty("hst.SES_USER_INFO", "");
            WebConstants.SES_USER_MENU = pro.getProperty("hst.SES_USER_MENU", "");
            WebConstants.GLOBAL_WEB_ROOT = pro.getProperty("hst.GLOBAL_WEB_ROOT", "");
            WebConstants.SCHEMA_CTAIS = pro.getProperty("hst.SCHEMA_CTAIS", "");
            WebConstants.SCHEMA_HST = pro.getProperty("hst.SCHEMA_HST", "");
            WebConstants.DOWNLOAD_SRC_PATH = pro.getProperty("hst.DOWNLOAD_SRC_PATH", "");
            WebConstants.DOWNLOAD_FILE_NAME = pro.getProperty("hst.DOWNLOAD_FILE_NAME", "");
            WebConstants.DOWNLOAD_MAX_SIZE = Long.parseLong(pro.getProperty("hst.DOWNLOAD_MAX_SIZE", ""));
            WebConstants.DOWNLOAD_BUFFER_SIZE = Integer.parseInt(pro.getProperty("hst.DOWNLOAD_BUFFER_SIZE", ""));
            WebConstants.UPLOAD_MAX_SIZE = Integer.parseInt(pro.getProperty("hst.UPLOAD_MAX_SIZE", ""));
            WebConstants.DEFAULT_BUFFER_SIZE = Integer.parseInt(pro.getProperty("hst.DEFAULT_BUFFER_SIZE", ""));
            WebConstants.DEFAULT_PAGE_NUM = Integer.parseInt(pro.getProperty("hst.DEFAULT_PAGE_NUM", ""));
            WebConstants.TEMP_PATH = pro.getProperty("hst.TEMP_PATH", "");
            WebConstants.DATA_SOURCE_LOCAL_CTAIS = pro.getProperty("hst.DATA_SOURCE_LOCAL_CTAIS", "");
            WebConstants.DATA_SOURCE_REMOTE_CTAIS = pro.getProperty("hst.DATA_SOURCE_REMOTE_CTAIS", "");
            WebConstants.DATA_SOURCE_PROJECT = pro.getProperty("hst.DATA_SOURCE_PROJECT", "");
            WebConstants.WORKING_TIME_Q = pro.getProperty("hst.WORKING_TIME_Q", "");
            WebConstants.WORKING_TIME_Z = pro.getProperty("hst.WORKING_TIME_Z", "");
            WebConstants.DATABASE_ENCODE = pro.getProperty("hst.DATABASE_ENCODE", "");
            WebConstants.MAX_SWJG_DM = pro.getProperty("hst.MAX_SWJG_DM", "");
            WebConstants.SUPPER_CZRY_DM = pro.getProperty("hst.SUPPER_CZRY_DM", "");
            WebConstants.WSSX_DOWNLOAD_ABSOLUTE_PATH = pro.getProperty("hst.WSSX_DOWNLOAD_ABSOLUTE_PATH", "");
            WebConstants.LOG_KZ_ERRORS = pro.getProperty("hst.LOG_KZ_ERRORS", "");
            WebConstants.LOG_KZ_TIME = pro.getProperty("hst.LOG_KZ_TIME", "");
            WebConstants.JHXT_URL = pro.getProperty("hst.JHXT_URL", "");
            WebConstants.WX_GZZLIST_URL = pro.getProperty("hst.WX_GZZLIST_URL", "");
            WebConstants.INITIAL_CONTEXT_FACTORY = pro.getProperty("initial_context_factory", "");
            WebConstants.PROVIDER_URL = pro.getProperty("provider_url", "");
            WebConstants.SECURITY_PRINCIPAL = pro.getProperty("security_principal", "");
            WebConstants.SECURITY_CREDENTIALS = pro.getProperty("security_credentials", "");
            WebConstants.INTERFACE_PROCEDURE_CONTROL = pro.getProperty("hst.interface_procedure_control", "");
            WebConstants.FWSK_IP = pro.getProperty("hst.FWSK_IP", "");
            WebConstants.FWSK_PORT = pro.getProperty("hst.FWSK_PORT", "");
            WebConstants.FWSK_SID = pro.getProperty("hst.FWSK_SID", "");
            WebConstants.FWSK_USERNAME = pro.getProperty("hst.FWSK_USERNAME", "");
            WebConstants.FWSK_PASSWORD = pro.getProperty("hst.FWSK_PASSWORD", "");
            WebConstants.LOCAL_SERVICE_IP = pro.getProperty("hst.LOCAL_SERVICE_IP", "");
            WebConstants.LOCAL_SERVICE_PORT = pro.getProperty("hst.LOCAL_SERVICE_PORT", "");
            WebConstants.WX_SERVICE_URL = pro.getProperty("hst.WX_SERVICE_URL", "");
            WebConstants.GT3_INITIAL_CONTEXT_FACTORY = pro.getProperty("hst.GT3_INITIAL_CONTEXT_FACTORY", "");
            WebConstants.GT3_PROVIDER_URL = pro.getProperty("hst.GT3_PROVIDER_URL", "");
            WebConstants.TAX_SERVICE_LOG = pro.getProperty("hst.TAX_SERVICE_LOG", "");
            WebConstants.GT3_LOG = pro.getProperty("hst.GT3_LOG", "");
            WebConstants.GT3_JK = pro.getProperty("hst.GT3_JK", "");
            WebConstants.GT3_CHANNEL_ID = pro.getProperty("hst.GT3_CHANNEL_ID", "");
            WebConstants.GT3_IDENTITYTYPE = pro.getProperty("hst.GT3_IDENTITYTYPE", "");
            WebConstants.GT3_SHHBSPT_SJRY = pro.getProperty("hst.GT3_SHHBSPT_SJRY", "");
            WebConstants.GT3_SHHBSPT_SJJG = pro.getProperty("hst.GT3_SHHBSPT_SJJG", "");
            WebConstants.GT3_DATABASE_ENCODE = pro.getProperty("hst.GT3_DATABASE_ENCODE", "");
            WebConstants.CTAIS2_TO_GT3 = pro.getProperty("hst.CTAIS2_TO_GT3", "");
            WebConstants.GT3JK_SJ_URL = pro.getProperty("hst.GT3JK_SJ_URL", "");
            WebConstants.TAX_HTTP_PUBLIC_SERVICE_URL = pro.getProperty("hst.TAX_HTTP_PUBLIC_SERVICE_URL", "");
            WebConstants.GT3JK_SJ_BSPT = pro.getProperty("hst.GT3JK_SJ_BSPT", "");
            WebConstants.BSPT_8406_KZ = pro.getProperty("hst.BSPT_8406_KZ", "");
            WebConstants.XS_WS_DBURL = pro.getProperty("hst.XS_WS_DBURL", "");
            WebConstants.XS_WS_USER = pro.getProperty("hst.XS_WS_USER", "");
            WebConstants.XS_WS_PWD = pro.getProperty("hst.XS_WS_PWD", "");
            WebConstants.HXZG_URL = pro.getProperty("hst.HXZG_URL", "");
            WebConstants.SMZ_RXBD_JK_GT3 = pro.getProperty("hst.SMZ_RXBD_JK_GT3", "");
            WebConstants.DSB_CLIENT_ID = pro.getProperty("dsb.CLIENT_ID", "");
            WebConstants.DSB_CLIENT_SECRET = pro.getProperty("dsb.CLIENT_SECRET", "");
            WebConstants.DSB_SERVICE_URL = pro.getProperty("dsb.DSB_SERVICE_URL", "");
            WebConstants.HX_FPDK_SERVICE_URL = pro.getProperty("hx.FPDK_SERVICE_URL", "");
            WebConstants.JHXT_TO_NEW = pro.getProperty("hst.JHXT_TO_NEW", "");
            WebConstants.ZJK_SERVICE_URL = pro.getProperty("hst.ZJK_SERVICE_URL", "");
            WebConstants.ZJK_FOR_QHJ__URL = pro.getProperty("hst.ZJK_FOR_QHJ__URL", "");
            WebConstants.MQ_TRANSFER_URL = pro.getProperty("hst.MQ_TRANSFER_URL", "");
            WebConstants.MQ_SERVICE_URL = pro.getProperty("hst.MQ_SERVICE_URL", "");
            WebConstants.TRANSFER_URL = pro.getProperty("hst.TRANSFER_URL", "");
            WebConstants.ZHDT_SERVICE_URL = pro.getProperty("hst.ZHDT_SERVICE_URL", "");
            WebConstants.SERVICE_VERSION = pro.getProperty("hst.SERVICE_VERSION", "");
            WebConstants.DS_YYQH_USERNAME = pro.getProperty("ds.DS_YYQH_USERNAME", "");
            WebConstants.DS_YYQH_URL = pro.getProperty("ds.DS_YYQH_URL", "");
            WebConstants.DS_YYQH_PASSWORD = pro.getProperty("ds.DS_YYQH_PASSWORD", "");
            WebConstants.CKRY_IMG_PATH = pro.getProperty("hst.CKRY_IMG_PATH", "");
            String[] fwkzStrs = pro.getProperty("hst.FWKZ_IGNORE_SET", "").split(",");
            WebConstants.FWKZ_IGNORE_SET = new HashSet<String>();
            WebConstants.FWKZ_IGNORE_SET.add("/");
            boolean bl = false;
            while (var4_7 < fwkzStrs.length) {
                WebConstants.FWKZ_IGNORE_SET.add(fwkzStrs[var4_7]);
                ++var4_7;
            }
        }
        catch (Exception e) {
            _logger.info((Object)e.getMessage());
        }
    }

    protected void initExceptionConfig() {
    }

    protected void initSystemLog() {
    }

    protected void initXtmlGnmkCzts() {
    }

    private void initZfpzConfig() {
        SAXReader saxReader = new SAXReader();
        try {
            Document document = saxReader.read(((Object)((Object)this)).getClass().getResourceAsStream("/zf_config.xml"));
            Element root = document.getRootElement();
            List zfpzs = root.elements("zfxxpz");
            HashMap<String, String> dbMap = new HashMap<String, String>();
            for (Element zfpz : zfpzs) {
                if (!"Y".equals(zfpz.elementText("yxbz"))) continue;
                String url = zfpz.elementText("url");
                Element ywidsElement = zfpz.element("ywids");
                List ywids = ywidsElement.elements("ywid");
                for (Element e : ywids) {
                    dbMap.put(e.getText(), url);
                }
            }
            WebConstants.TAX_ZFSZ_MAP = dbMap;
            System.out.println("Root: " + root.getName());
        }
        catch (DocumentException e) {
            e.printStackTrace();
        }
    }

    private void initForwardConfig() {
        SAXReader saxReader = new SAXReader();
        try {
            Document document = saxReader.read(((Object)((Object)this)).getClass().getResourceAsStream("/forward_config.xml"));
            Element root = document.getRootElement();
            List forwards = root.elements("forward");
            HashMap<String, String> map = new HashMap<String, String>();
            for (Element forward : forwards) {
                if (!"Y".equals(forward.elementText("qybz"))) continue;
                String url = forward.elementText("url");
                Element ywidsElement = forward.element("ywids");
                List ywids = ywidsElement.elements("ywid");
                for (Element e : ywids) {
                    map.put(e.getText(), url);
                }
            }
            WebConstants.TAX_FORWARD_MAP = map;
        }
        catch (DocumentException e) {
            _logger.error((Object)("\u52a0\u8f7dforward_config.xml\u62a5\u9519" + (Object)((Object)e)));
            e.printStackTrace();
        }
    }

    public void initSmzbsBsdtDjxh() throws Exception {
        String swjgDm;
        String BsdtDjxh;
        WebConstants.SMZ_RXBD_BSDT_DJXH = BsdtDjxh = (String)this.smzbsSqlMapClientTemplate.queryForObject("queryBsdtDjxhJhj");
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("key", "BS_TAX_AUTHORITY_NUM");
        WebConstants.SMZ_RXBD_SWJG_DM = swjgDm = (String)this.smzbsSqlMapClientTemplate.queryForObject("selectParmValueByKey", map);
        map.put("value", WebConstants.SERVICE_VERSION);
        this.smzbsSqlMapClientTemplate.update("updateServiceVersion", map);
    }

    public void initQhbzPz() throws Exception {
        String gt3CodeQhbzStr = (String)this.smzbsSqlMapClientTemplate.queryForObject("queyrySmzRxbdCodeQhbz");
        String[] qhbzArr = gt3CodeQhbzStr.split(",");
        WebConstants.SMZ_RXBD_CODE_QHBZ = new HashMap();
        int i = 0;
        while (i < qhbzArr.length) {
            String[] arr = qhbzArr[i].split(":");
            WebConstants.SMZ_RXBD_CODE_QHBZ.put(arr[0], arr[1]);
            ++i;
        }
    }

    public void initJhxtXtcs() throws Exception {
        List dataList = this.smzbsSqlMapClientTemplate.queryForList("queryJhxtXtcs");
        WebConstants.JHXT_XTCS = new HashMap<String, String>();
        for (JhxtXtcsDomain data : dataList) {
            WebConstants.JHXT_XTCS.put(data.getXtcsXh(), data.getXtcsValue());
        }
    }
}
