/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.springframework.beans.BeanUtils
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.stereotype.Repository
 *  org.springframework.transaction.annotation.Propagation
 *  org.springframework.transaction.annotation.Transactional
 */
package com.hst.taxService.dao.imp;

import com.hst.framework.common.HstSqlMapClientTemplate;
import com.hst.framework.constants.AppServiceConstants;
import com.hst.framework.util.HstDateUtil;
import com.hst.framework.util.HstEncodeUtil;
import com.hst.framework.util.HstToolsUtil;
import com.hst.taxService.dao.XshsCommonDao;
import com.hst.taxService.domain.gt3.GsglSbGrsdsScjysdARequestDomain;
import com.hst.taxService.domain.gt3.HxzgSbBcFxmtysbDomain;
import com.hst.taxService.domain.gt3.HxzgSbBcFxmtysbRequestDomain;
import com.hst.taxService.domain.gt3.HxzgSbZzsXgmSbSaveRequestDomain;
import com.hst.taxService.domain.gt3.HxzgSbZzsXgmSbSaveZzsxgmGridlbDomain;
import com.hst.taxService.domain.gt3.ZrrdjxxDomain;
import com.hst.taxService.domain.xshs.TaskJkSbDomain;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Repository
public class XshsCommonDaoImp
implements XshsCommonDao {
    @Autowired
    private HstSqlMapClientTemplate xshsSqlMapClientTemplate;

    @Override
    public void updateXshsNsrZrrPldj(ZrrdjxxDomain domain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        if (HstToolsUtil.isNullOrEmpty(domain.getDjxh())) {
            domain.setDjxh("");
            domain.setDjzt("N");
            domain.setDjrq("");
        } else {
            domain.setDjzt("Y");
            domain.setDjrq(HstDateUtil.toDateString(new Date(), AppServiceConstants.TIME_DATETIME_FORMAT));
        }
        if (HstToolsUtil.isNullOrEmpty(domain.getNsrsbh())) {
            domain.setNsrsbh("");
        }
        if (HstToolsUtil.isNullOrEmpty(domain.getErrMess())) {
            domain.setErrMess("");
        }
        map.put("sfzjhm", domain.getSfzjhm());
        map.put("nsrsbh", domain.getNsrsbh());
        map.put("djxh", domain.getDjxh());
        map.put("errMess", HstEncodeUtil.GBK2ISO(domain.getErrMess()));
        map.put("djrq", domain.getDjrq());
        map.put("djzt", domain.getDjzt());
        this.xshsSqlMapClientTemplate.update("updateXshsNsrZrrPldj", map);
    }

    @Override
    public List<ZrrdjxxDomain> queryZrrpldjList() throws Exception {
        List dataList = null;
        HashMap map = new HashMap();
        dataList = this.xshsSqlMapClientTemplate.queryForList("selectZrrpldjList", map);
        return dataList;
    }

    @Override
    public List<TaskJkSbDomain> queryTaskSb(String tdId) throws Exception {
        List dataList = null;
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("tdId", tdId);
        dataList = this.xshsSqlMapClientTemplate.queryForList("selectTaskJdSbDrList", map);
        return dataList;
    }

    @Override
    public void updateTaskYxjg(TaskJkSbDomain domain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        if ("00".equals(domain.getCode())) {
            map.put("zt", "Y");
        } else {
            map.put("zt", "N");
        }
        map.put("kssj", domain.getKssj());
        map.put("jssj", domain.getJssj());
        if (!HstToolsUtil.isNullOrEmpty(domain.getMess())) {
            if (domain.getMess().length() > 3000) {
                map.put("errMess", HstEncodeUtil.GBK2ISO(domain.getMess().substring(0, 3000)));
            } else {
                map.put("errMess", HstEncodeUtil.GBK2ISO(domain.getMess()));
            }
        } else {
            map.put("errMess", "");
        }
        map.put("sbdrUuid", domain.getSbdrUuid());
        this.xshsSqlMapClientTemplate.update("updateTaskYxjg", map);
    }

    @Override
    @Transactional(value="myTransactionManager_Xshs", propagation=Propagation.REQUIRED)
    public List<HxzgSbZzsXgmSbSaveZzsxgmGridlbDomain> queryDrcxList(TaskJkSbDomain domain, HxzgSbZzsXgmSbSaveRequestDomain appDomain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("ksjsXh", domain.getKsjsXh());
        map.put("czryDm", "99999999999");
        map.put("code", "");
        map.put("mess", "");
        map.put("dataList", null);
        if ("Y".equals(domain.getSebz())) {
            this.xshsSqlMapClientTemplate.queryForObjectByCurr("pGt3SkzsLSbdrDrcx", map, "dataList", "dataRtn");
        } else {
            this.xshsSqlMapClientTemplate.queryForObjectByCurr("pGt3SkzsSbdrDrcx", map, "dataList", "dataRtn");
        }
        domain.setCode((String)map.get("code"));
        domain.setMess(HstEncodeUtil.ISO2GBK((String)map.get("mess")));
        if ("00".equals(domain.getCode())) {
            List dataList = (List)map.get("dataList");
            List dataRtn = (List)map.get("dataRtn");
            BeanUtils.copyProperties(dataRtn.get(0), (Object)appDomain);
            return dataList;
        }
        return new ArrayList<HxzgSbZzsXgmSbSaveZzsxgmGridlbDomain>();
    }

    @Override
    @Transactional(value="myTransactionManager_Xshs", propagation=Propagation.REQUIRED)
    public List<HxzgSbBcFxmtysbDomain> queryFjsDrcxList(TaskJkSbDomain domain, HxzgSbBcFxmtysbRequestDomain appDomain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("ksjsXh", domain.getKsjsXh());
        map.put("czryDm", "99999999999");
        map.put("code", "");
        map.put("mess", "");
        map.put("dataList", null);
        if ("Y".equals(domain.getSebz())) {
            this.xshsSqlMapClientTemplate.queryForObjectByCurr("pGt3SkzsLSbdrFjsDrcx", map, "dataList", "dataRtn");
        } else {
            this.xshsSqlMapClientTemplate.queryForObjectByCurr("pGt3SkzsSbdrFjsDrcx", map, "dataList", "dataRtn");
        }
        domain.setCode((String)map.get("code"));
        domain.setMess(HstEncodeUtil.ISO2GBK((String)map.get("mess")));
        if ("00".equals(domain.getCode())) {
            List dataList = (List)map.get("dataList");
            List dataRtn = (List)map.get("dataRtn");
            BeanUtils.copyProperties(dataRtn.get(0), (Object)appDomain);
            return dataList;
        }
        return new ArrayList<HxzgSbBcFxmtysbDomain>();
    }

    @Override
    @Transactional(value="myTransactionManager_Xshs", propagation=Propagation.REQUIRED)
    public GsglSbGrsdsScjysdARequestDomain queryGrsdsDrcxList(TaskJkSbDomain domain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("ksjsXh", domain.getKsjsXh());
        map.put("czryDm", "99999999999");
        map.put("code", "");
        map.put("mess", "");
        map.put("dataList", null);
        if ("Y".equals(domain.getSebz())) {
            this.xshsSqlMapClientTemplate.queryForObjectByCurr("pGt3SkzsLSbdrGrsdsDrcx", map, "dataRtn");
        } else {
            this.xshsSqlMapClientTemplate.queryForObjectByCurr("pGt3SkzsSbdrGrsdsDrcx", map, "dataRtn");
        }
        List dataList = (List)map.get("dataRtn");
        domain.setCode((String)map.get("code"));
        domain.setMess(HstEncodeUtil.ISO2GBK((String)map.get("mess")));
        if ("00".equals(domain.getCode())) {
            return (GsglSbGrsdsScjysdARequestDomain)dataList.get(0);
        }
        return new GsglSbGrsdsScjysdARequestDomain();
    }

    @Override
    public void saveDrjg(TaskJkSbDomain domain) throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("ksjsXh", domain.getKsjsXh());
        map.put("czryDm", "99999999999");
        if ("00".equals(domain.getCode())) {
            map.put("drjg", "Y");
            map.put("errMess", HstEncodeUtil.GBK2ISO(domain.getMess()));
            map.put("pzxh", domain.getPzxh());
        } else {
            map.put("drjg", "N");
            map.put("errMess", HstEncodeUtil.GBK2ISO(domain.getMess()));
            map.put("pzxh", domain.getPzxh());
        }
        if ("Y".equals(domain.getSebz())) {
            this.xshsSqlMapClientTemplate.queryForObject("pGt3SkzsLSbdrDrsave", map);
        } else {
            this.xshsSqlMapClientTemplate.queryForObject("pGt3SkzsSbdrDrsave", map);
        }
    }

    @Override
    public Connection getXshsConn() throws Exception {
        return this.xshsSqlMapClientTemplate.getDataSource().getConnection();
    }
}
