package com.hzya.frame.seeyon.invoice.dao.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.execsql.service.IExecSqlService;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao;
import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

@Repository(value = "InvoiceDaoImpl")
public class InvoiceDaoImpl extends MybatisGenericDao<InvoiceEntity,String> implements IInvoiceDao {
    @Autowired
    private IExecSqlService execSqlService;

    private Logger logger = LogManager.getLogger(super.getClass());

    @DS("#entity.dataSourceCode")
    @Override
    public List<HashMap<String, Object>> queryInvoice(String str, MdmModuleSourceEntity entity) {
        try {
            List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
            return hashMaps;
        }catch (Exception e){
            logger.info("没有需要推送税务的数据");
            return null;
        }
    }

    @DS("#entity.dataSourceCode")
    @Override
    public List<InvoiceEntity> queryInvoiceResult(InvoiceEntity entity) {
        return (List<InvoiceEntity>) super.selectList("queryInvoiceResult",entity);
    }

    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateInvoicePush(InvoiceEntity entity) {
        return super.update("updateInvoicePush",entity);
    }

    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateInvoiceUrl(InvoiceEntity entity) {
        return super.update("updateInvoiceUrl",entity);
    }

    @DS("#entity.dataSourceCode")
    @Override
    public Integer updateInvoiceResult(InvoiceEntity entity) {
        return super.update("updateInvoiceResult",entity);
    }

    @DS("#entity.dataSourceCode")
    @Override
    public List<InvoiceEntity> queryInputInvoiceResult(InvoiceEntity entity) {
        return  (List<InvoiceEntity>)super.selectList("queryInputInvoiceResult",entity);
    }
}
