/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.apache.tomcat.dbcp.dbcp.BasicDataSource
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.stereotype.Service
 */
package com.hst.taxService.service.imp;

import com.hst.common.domain.BaseAppServiceDomain;
import com.hst.common.domain.TaxCommonReturnDomain;
import com.hst.common.service.imp.BaseBusinessServiceImp;
import com.hst.common.util.DBUtil;
import com.hst.framework.util.HstToolsUtil;
import com.hst.taxService.dao.Gt3CommonDao;
import com.hst.taxService.dao.TaxPublicQueryDao;
import com.hst.taxService.dao.XshsCommonDao;
import com.hst.taxService.dao.ZjzkWlfpCommonDao;
import com.hst.taxService.domain.PublicExeSqlRequestDomain;
import com.hst.taxService.domain.PublicProcQueryRequestDomain;
import com.hst.taxService.domain.PublicProcQueryResponseDomain;
import com.hst.taxService.domain.PublicSQLQueryRequestDomain;
import com.hst.taxService.domain.PublicSQLQueryResponseDomain;
import com.hst.taxService.domain.PublicSelectSqlDomain;
import com.hst.taxService.service.TaxPublicQueryService;
import java.sql.Connection;
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TaxPublicQueryServiceImp
extends BaseBusinessServiceImp
implements TaxPublicQueryService {
    @Autowired
    private TaxPublicQueryDao dao;
    @Autowired
    private Gt3CommonDao gt3Dao;
    @Autowired
    private XshsCommonDao xshsDao;
    @Autowired
    private ZjzkWlfpCommonDao zjzkWlfpDao;
    @Autowired
    private BasicDataSource fwskDs;
    @Autowired
    private BasicDataSource jcebDs;
    @Autowired
    private BasicDataSource jdptDs;

    @Override
    public TaxCommonReturnDomain publicSqlQuery(BaseAppServiceDomain appDomain) throws Exception {
        Connection conn;
        PublicSQLQueryResponseDomain response;
        PublicSQLQueryRequestDomain request;
        block20: {
            block19: {
                String sql;
                block18: {
                    block17: {
                        block16: {
                            request = (PublicSQLQueryRequestDomain)appDomain;
                            response = new PublicSQLQueryResponseDomain();
                            conn = null;
                            response.setCode("00");
                            _logger.debug((Object)("c\u4f20\u5165\u53c2\u6570" + request.getSQL()));
                            if (!HstToolsUtil.isNullOrEmpty(request.getSQL())) break block16;
                            response.setCode("01");
                            response.setMess("\u4f20\u5165sql\u8bed\u53e5\u4e3a\u7a7a\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                            PublicSQLQueryResponseDomain publicSQLQueryResponseDomain = response;
                            DBUtil.close(conn);
                            return publicSQLQueryResponseDomain;
                        }
                        if (!HstToolsUtil.isNullOrEmpty(request.getCXDB())) break block17;
                        response.setCode("01");
                        response.setMess("\u4f20\u5165\u6307\u5b9a\u67e5\u8be2\u6570\u636e\u5e93\u4e3a\u7a7a\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                        PublicSQLQueryResponseDomain publicSQLQueryResponseDomain = response;
                        DBUtil.close(conn);
                        return publicSQLQueryResponseDomain;
                    }
                    sql = request.getSQL().toUpperCase();
                    if (sql.indexOf("INSERT") < 0 && sql.indexOf("DELETE") < 0 && sql.indexOf("UPDATE") < 0) break block18;
                    response.setCode("01");
                    response.setMess("\u975e\u6cd5\u8bbf\u95ee!");
                    PublicSQLQueryResponseDomain publicSQLQueryResponseDomain = response;
                    DBUtil.close(conn);
                    return publicSQLQueryResponseDomain;
                }
                request.setSQL(sql);
                _logger.debug((Object)("\u6267\u884csql\u8bed\u53e5\uff1a" + sql));
                if ("1".equals(request.getCXDB())) {
                    conn = this.gt3Dao.getGt3Conn();
                    break block19;
                }
                if ("2".equals(request.getCXDB())) {
                    conn = this.dao.getGlptConn();
                    break block19;
                }
                if ("3".equals(request.getCXDB())) {
                    conn = this.xshsDao.getXshsConn();
                    break block19;
                }
                if ("4".equals(request.getCXDB())) {
                    this.zjzkWlfpDao.getZjzkWlfpConn();
                    break block19;
                }
                if ("5".equals(request.getCXDB())) {
                    conn = this.fwskDs.getConnection();
                    break block19;
                }
                if ("6".equals(request.getCXDB())) {
                    conn = this.jcebDs.getConnection();
                    break block19;
                }
                if ("7".equals(request.getCXDB())) {
                    conn = this.jdptDs.getConnection();
                    break block19;
                }
                response.setCode("01");
                response.setMess("\u53c2\u6570\u975e\u6cd5\uff0c\u62d2\u7edd\u8bbf\u95ee!");
                PublicSQLQueryResponseDomain publicSQLQueryResponseDomain = response;
                DBUtil.close(conn);
                return publicSQLQueryResponseDomain;
            }
            if (conn != null) break block20;
            response.setCode("01");
            response.setMess("\u975e\u6cd5\u8bbf\u95ee!");
            PublicSQLQueryResponseDomain publicSQLQueryResponseDomain = response;
            DBUtil.close(conn);
            return publicSQLQueryResponseDomain;
        }
        try {
            try {
                this.dao.publicSqlQuery(conn, request, response);
            }
            catch (Exception e) {
                e.getStackTrace();
                _logger.error((Object)e.getMessage());
                throw new Exception(e);
            }
        }
        catch (Throwable throwable) {
            DBUtil.close(conn);
            throw throwable;
        }
        DBUtil.close(conn);
        return response;
    }

    @Override
    public TaxCommonReturnDomain publiProcQuery(BaseAppServiceDomain appDomain) throws Exception {
        Connection conn;
        PublicProcQueryResponseDomain response;
        PublicProcQueryRequestDomain request;
        block17: {
            block16: {
                block15: {
                    block14: {
                        block13: {
                            request = (PublicProcQueryRequestDomain)appDomain;
                            response = new PublicProcQueryResponseDomain();
                            conn = null;
                            response.setCode("00");
                            if (!HstToolsUtil.isNullOrEmpty(request.getCXDB())) break block13;
                            response.setCode("01");
                            response.setMess("\u4f20\u5165\u6307\u5b9a\u67e5\u8be2\u6570\u636e\u5e93\u4e3a\u7a7a\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                            PublicProcQueryResponseDomain publicProcQueryResponseDomain = response;
                            DBUtil.close(conn);
                            return publicProcQueryResponseDomain;
                        }
                        if (!HstToolsUtil.isNullOrEmpty(request.getPROC())) break block14;
                        response.setCode("01");
                        response.setMess("\u4f20\u5165\u5b58\u50a8\u8fc7\u7a0b\u4e3a\u7a7a\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                        PublicProcQueryResponseDomain publicProcQueryResponseDomain = response;
                        DBUtil.close(conn);
                        return publicProcQueryResponseDomain;
                    }
                    if (!HstToolsUtil.isNullOrEmpty(request.getWHERE())) break block15;
                    response.setCode("01");
                    response.setMess("\u4f20\u5165where\u4e3a\u7a7a\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                    PublicProcQueryResponseDomain publicProcQueryResponseDomain = response;
                    DBUtil.close(conn);
                    return publicProcQueryResponseDomain;
                }
                if ("1".equals(request.getCXDB())) {
                    conn = this.gt3Dao.getGt3Conn();
                    break block16;
                }
                if ("2".equals(request.getCXDB())) {
                    conn = this.dao.getGlptConn();
                    break block16;
                }
                if ("3".equals(request.getCXDB())) {
                    conn = this.xshsDao.getXshsConn();
                    break block16;
                }
                if ("4".equals(request.getCXDB())) {
                    conn = this.zjzkWlfpDao.getZjzkWlfpConn();
                    break block16;
                }
                response.setCode("01");
                response.setMess("\u53c2\u6570\u975e\u6cd5\uff0c\u62d2\u7edd\u8bbf\u95ee!");
                PublicProcQueryResponseDomain publicProcQueryResponseDomain = response;
                DBUtil.close(conn);
                return publicProcQueryResponseDomain;
            }
            if (conn != null) break block17;
            response.setCode("01");
            response.setMess("\u975e\u6cd5\u8bbf\u95ee!");
            PublicProcQueryResponseDomain publicProcQueryResponseDomain = response;
            DBUtil.close(conn);
            return publicProcQueryResponseDomain;
        }
        try {
            try {
                this.dao.publicProcQuery(conn, request, response);
            }
            catch (Exception e) {
                e.getStackTrace();
                _logger.error((Object)e.getMessage());
                throw new Exception(e);
            }
        }
        catch (Throwable throwable) {
            DBUtil.close(conn);
            throw throwable;
        }
        DBUtil.close(conn);
        return response;
    }

    @Override
    public TaxCommonReturnDomain queryDbExeSql(BaseAppServiceDomain appDomain) throws Exception {
        PublicExeSqlRequestDomain request = (PublicExeSqlRequestDomain)appDomain;
        PublicSQLQueryResponseDomain response = new PublicSQLQueryResponseDomain();
        try {
            response.setCode("00");
            if (HstToolsUtil.isNullOrEmpty(request.getSQLID())) {
                response.setCode("01");
                response.setMess("\u4f20\u5165\u6307\u5b9aSQLID\u4e3a\u7a7a\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                return response;
            }
            PublicSelectSqlDomain sqlDomain = this.dao.querySql(request);
            if (sqlDomain == null) {
                response.setCode("01");
                response.setMess("sql\u8bed\u53e5\u4e3a\u7ef4\u62a4\uff0cSQLID = " + request.getSQLID() + "\uff0c\u8bf7\u60a8\u68c0\u67e5!");
                return response;
            }
            if (!"00".equals(sqlDomain.getCode())) {
                response.setCode("01");
                response.setMess(sqlDomain.getMess());
                return response;
            }
            _logger.debug((Object)("\u6267\u884csql\u8bed\u53e5\uff1a" + sqlDomain.getSql()));
            PublicSQLQueryRequestDomain requestDomain = new PublicSQLQueryRequestDomain();
            requestDomain.setCXDB(sqlDomain.getSqlDb());
            requestDomain.setSQL(sqlDomain.getSql());
            return this.publicSqlQuery(requestDomain);
        }
        catch (Exception e) {
            e.getStackTrace();
            _logger.error((Object)e.getMessage());
            throw new Exception(e);
        }
    }
}
