/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.apache.commons.beanutils.BeanUtils
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.orm.ibatis.SqlMapClientTemplate
 *  org.springframework.stereotype.Repository
 */
package com.hst.taxService.dao.imp;

import com.hst.business.domain.XtGt3LogDomain;
import com.hst.business.domain.XtGt3SmbsLogDomain;
import com.hst.business.domain.XtTaxServiceLogDomain;
import com.hst.common.bo.XtGt3Log;
import com.hst.common.bo.XtGt3SmbsLog;
import com.hst.common.bo.XtGt3SmbsRxbdLog;
import com.hst.common.bo.XtGt3SmbsSmcjLog;
import com.hst.common.bo.XtTaxServiceLog;
import com.hst.framework.common.HstSqlMapClientTemplate;
import com.hst.framework.util.HstToolsUtil;
import com.hst.taxService.dao.TaxLogDao;
import java.util.HashMap;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class TaxLogDaoImp
implements TaxLogDao {
    @Autowired
    private HstSqlMapClientTemplate sqlMapClientTemplate;
    @Autowired
    private SqlMapClientTemplate smzbsSqlMapClientTemplate;

    @Override
    public void saveTaxLogDomain(XtTaxServiceLogDomain domain) throws Exception {
        XtTaxServiceLog bo = new XtTaxServiceLog();
        if (!HstToolsUtil.isNullOrEmpty(domain.getLogXh())) {
            bo.setLogXh(domain.getLogXh());
            bo.setClbz(domain.getClbz());
            bo.setBackTime(domain.getBackTime());
            if (!HstToolsUtil.isNullOrEmpty(domain.getBackData())) {
                bo.setBackData(domain.getBackData().replaceAll("%", "%25"));
            }
            if (HstToolsUtil.isNullOrEmpty(domain.getErrMess())) {
                bo.setErrMess("");
            } else {
                bo.setErrMess(domain.getErrMess().replaceAll("%", "%25"));
            }
            this.sqlMapClientTemplate.update("updateXtTaxServiceLogByKey", bo);
        } else {
            BeanUtils.copyProperties((Object)bo, (Object)domain);
            if (!HstToolsUtil.isNullOrEmpty(bo.getRecvData())) {
                bo.setRecvData(bo.getRecvData().replaceAll("%", "%25"));
            }
            this.sqlMapClientTemplate.insert("insertXtTaxServiceLog", bo);
            domain.setLogXh(bo.getLogXh());
        }
    }

    @Override
    public XtTaxServiceLogDomain getTaxLogDomainByKey(XtTaxServiceLogDomain domain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("logXh", domain.getLogXh());
        domain = (XtTaxServiceLogDomain)this.sqlMapClientTemplate.queryForObject("selectXtTaxServiceLogByKey", map);
        return domain;
    }

    @Override
    public void saveGt3LogDomain(XtGt3LogDomain domain) throws Exception {
        XtGt3Log bo = new XtGt3Log();
        if (!HstToolsUtil.isNullOrEmpty(domain.getLogXh())) {
            bo.setLogXh(domain.getLogXh());
            bo.setClbz(domain.getClbz());
            bo.setResCode(domain.getResCode());
            if (!HstToolsUtil.isNullOrEmpty(domain.getResMess())) {
                bo.setResMess(domain.getResMess().replaceAll("%", "%25"));
            }
            bo.setResTime(domain.getResTime());
            if (!HstToolsUtil.isNullOrEmpty(domain.getResData())) {
                bo.setResData(domain.getResData().replaceAll("%", "%25"));
            }
            bo.setErrMess(domain.getErrMess());
            this.sqlMapClientTemplate.update("updateXtGt3LogByKey", bo);
        } else {
            BeanUtils.copyProperties((Object)bo, (Object)domain);
            if (!HstToolsUtil.isNullOrEmpty(bo.getReqData())) {
                bo.setReqData(bo.getReqData().replaceAll("%", "%25"));
            }
            this.sqlMapClientTemplate.insert("insertXtGt3Log", bo);
            domain.setLogXh(bo.getLogXh());
        }
    }

    @Override
    public XtGt3LogDomain getGt3LogDomainByKey(XtGt3LogDomain domain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("logXh", domain.getLogXh());
        domain = (XtGt3LogDomain)this.sqlMapClientTemplate.queryForObject("selectXtGt3LogByKey", map);
        return domain;
    }

    public void saveGt3SmbzLogDomain(XtGt3SmbsLogDomain domain) throws Exception {
        XtGt3SmbsLog bo = new XtGt3SmbsLog();
        if (!HstToolsUtil.isNullOrEmpty(domain.getLogXh())) {
            bo.setLogXh(domain.getLogXh());
            bo.setClbz(domain.getClbz());
            bo.setResCode(domain.getResCode());
            if (!HstToolsUtil.isNullOrEmpty(domain.getResMess())) {
                bo.setResMess(domain.getResMess().replaceAll("%", "%25"));
            }
            bo.setResTime(domain.getResTime());
            if (!HstToolsUtil.isNullOrEmpty(domain.getResData())) {
                bo.setResData(domain.getResData().replaceAll("%", "%25"));
            }
            bo.setErrMess(domain.getErrMess());
            bo.setTimeUsed(domain.getTimeUsed());
            this.smzbsSqlMapClientTemplate.update("updateXtGt3SmbsLogByKey_sqlServer", (Object)bo);
        } else {
            BeanUtils.copyProperties((Object)bo, (Object)domain);
            if (!HstToolsUtil.isNullOrEmpty(bo.getReqData())) {
                bo.setReqData(bo.getReqData().replaceAll("%", "%25"));
            }
            this.smzbsSqlMapClientTemplate.insert("insertXtGt3SmbsLog_sqlServer", (Object)bo);
            domain.setLogXh(bo.getLogXh());
        }
    }

    public void saveSmzRxbdLog(XtGt3SmbsRxbdLog domain) throws Exception {
        this.smzbsSqlMapClientTemplate.insert("insertXtGt3SmbsRxbdLog_sqlServer", (Object)domain);
    }

    public void saveSmzSmcjLog(XtGt3SmbsSmcjLog domain) throws Exception {
        this.smzbsSqlMapClientTemplate.insert("insertXtGt3SmbsSmcjLog_sqlServer", (Object)domain);
    }
}
