<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.dxhy.jxpt.baseService.rzInvoice.dao.RzRecordInvoiceDao" >

	<resultMap id="BaseResultMap"
			   type="com.dxhy.api.model.rz.rzInvoice.TDxRecordInvoicePreRzVo">
		<result column="invoice_code" property="invoiceCode"/>
		<result column="invoice_no" property="invoiceNo"/>
		<result column="eleInvoiceNo" property="eleInvoiceNo"/>
		<result column="kprq" property="invoiceDate"/>
		<result column="invoice_type" property="invoiceType"/>
		<result column="gfsh" property="gfsh"/>
		<result column="gfmc" property="gfmc"/>
		<result column="xf_tax_no" property="xfsh"/>
		<result column="xf_name" property="xfmc"/>
		<result column="invoice_amount" property="invoiceAmount"/>
		<result column="tax_amount" property="taxAmount"/>
		<result column="dk_tax_amount" property="dkTaxAmount"/>
		<result column="invoice_status" property="invoiceStatus"/>
		<result column="rzh_date" property="rzsj"/>
		<result column="qs_date" property="qsrq"/>
		<result column="dqskssq" property="skssq"/>
		<result column="auth_status" property="rzclzt"/>
		<result column="qs_type" property="qsfs"/>
		<result column="qs_status" property="qszt"/>
		<result column="qs_name" property="qsr"/>
		<result column="rzh_yesorno" property="rzzt"/>
		<result column="deptId" property="deptId"/>
		<result column="deptName" property="businessName"/>
		<result column="confirm_user" property="rzhr"/>
		<result column="glzt" property="glzt"/>
		<result column="uuid" property="uuid"/>
		<result column="bdk_status" property="bdkStatus"/>
		<result column="export_mark" property="exportMark"/>
		<result column="scan_id" property="scanId"/>
		<result column="in_account_status" property="inAccountStatus"/>
		<result column="settle_source" property="settleSource"/>
		<result column="settlement_no" property="settlementNo"/>
		<result column="settlement_status" property="settlementStatus"/>
		<result column="voucher_number" property="voucherNumber"/>
		<result column="total_amount" property="totalAmount"/>

		<result column="fprzsq" property="fprzsq" jdbcType="VARCHAR" />
		<result column="fprz_auth_status" property="fprzAuthStatus" jdbcType="VARCHAR" />
		<result column="fprzlx" property="fprzlx" jdbcType="VARCHAR" />
		<result column="fprzsj" property="fprzsj" jdbcType="VARCHAR" />
		<result column="fprzsbyy" property="fprzsbyy" jdbcType="VARCHAR" />
		<result column="rzr" property="rzr" jdbcType="VARCHAR" />
	</resultMap>

    <resultMap id="BbfpzhcxhjResultMap"
               type="com.dxhy.api.model.rz.rzInvoice.TDxRecordInvoicePreRzVo">
        <result column="hjsl" property="id"/>
        <result column="hjje" property="invoiceAmount"/>
        <result column="hjse" property="taxAmount"/>
    </resultMap>

	<!--待入账发票查询-->
	<select databaseId="mysql" id="selectPreRzInvoiceList"  parameterType="java.util.Map"
			resultMap="BaseResultMap">
			select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,DATE_FORMAT(t.invoice_date,'%Y-%m-%d') kprq,t.gf_tax_no
		gfsh,t.gf_name gfmc,
		t.xf_tax_no,t.xf_name,t.tax_amount,t.dk_tax_amount,t.invoice_status,t.invoice_amount,DATE_FORMAT(t.rzh_date,'%Y-%m-%d')
		rzh_date ,DATE_FORMAT(t.qs_date,'%Y-%m-%d') qs_date,t.rzh_type,t.dept_id deptId,
		t.gx_user_name,t.rzh_belong_date
		dqskssq,t.auth_status,t.qs_type,t.qs_status,t.confirm_user,t.qs_name,t.rzh_yesorno,
		t.invoice_type , t.dept_name deptName,t.glzt
		glzt,t.uuid,t.bdk_status,t.scan_id,t.in_account_status,t.settle_source,
		t.settlement_no,
		t.settlement_status,t.voucher_number,t.total_amount
		from t_dx_record_invoice t
		WHERE t.company = #{company} and t.invoice_date between #{kpksrq} and #{kpjsrq}
		and t.gf_tax_no in
		<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and invoice_status in ('0','7')
		and glzt = '0'
		and lq_hzsdbs = 'N'
		and (lq_rzzt = '01' or lq_rzzt = '03')
		<!--待入账查询，特定字段固定值-->

		<!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->
		<if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
			and t.lq_hzsdbs = #{lqHzsdbs}
		</if>
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
			and t.lq_rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->

		<if
				test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
			and t.invoice_status = #{invoiceStatus}
		</if>
		<if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
			and t.qs_status = #{qszt}
		</if>
		<if test="voucherNumber != null and voucherNumber != ''">
			and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
		</if>
		<if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
			and t.rzh_yesorno = #{rzzt}
		</if>
		<!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
			and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
			and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>
		<if
				test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
			and t.rzh_type = #{fprzfs}
		</if>
		<if
				test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
			and t.auth_status = #{fprzclzt}
		</if>
		<if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
			and t.bdk_status = #{rzlx}
		</if>
		<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
			and t.xf_name like CONCAT(#{xfmc},'%')
		</if>
		<if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
			and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
		</if>
		<if test="amountMin!=null and amountMin!=''">
			and t.invoice_amount &gt;= #{amountMin}
		</if>

		<if test="amountMax!=null and amountMax!=''">
			and t.invoice_amount &lt;= #{amountMax}
		</if>
		<if test="taxAmountMin!=null and taxAmountMin!=''">
			and t.tax_amount &gt;= #{taxAmountMin}
		</if>

		<if test="taxAmountMax!=null and taxAmountMax!=''">
			and t.tax_amount &lt;= #{taxAmountMax}
		</if>

		<if test="qsr != null and qsr != '' and qsr != 'null' ">
			and t.qs_name like concat('%',#{qsr},'%')
		</if>
		<if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
			and t.confirm_user like concat('%',#{rzhr},'%')
		</if>
		<if test="settlementNo != null and settlementNo != ''">
			and t.settlement_no like concat(#{settlementNo},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and t.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and t.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
			and t.rzh_date between #{rzksrq} and #{rzjsrq}
		</if>
		<if test="skssq != null and skssq != '' and skssq != 'null' ">
			and t.rzh_belong_date = #{skssq}
		</if>
		<if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
			and t.qs_type = #{qsfs}
		</if>
		<if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
			and t.qs_date between #{qsksrq} and #{qsjsrq}
		</if>
		<if
				test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
			and t.dept_id = #{businessCode}
		</if>
		<if test="businessCode==''">
			and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
		</if>
		<if test='businessCode == "99" and business!=null and business.size()>0'>
			and (t.dept_id in
			<foreach collection="business" index="index" item="item" open="(" separator="," close="">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		<if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
			and t.in_account_status = #{inAccountStatus}
		</if>
		order by t.invoice_date desc
	</select>

	<select databaseId="oracle" id="selectPreRzInvoiceList"  parameterType="java.util.Map"
			resultMap="BaseResultMap">
		select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,TO_CHAR(t.invoice_date, 'yyyy-MM-dd') kprq,t.gf_tax_no
		gfsh,t.gf_name gfmc,
		t.xf_tax_no,t.xf_name,t.tax_amount,t.dk_tax_amount,t.invoice_status,t.invoice_amount,TO_CHAR(t.rzh_date, 'yyyy-MM-dd')
		rzh_date ,TO_CHAR(t.qs_date, 'yyyy-MM-dd') qs_date,t.rzh_type,t.dept_id deptId,
		t.gx_user_name,t.rzh_belong_date
		dqskssq,t.auth_status,t.qs_type,t.qs_status,t.confirm_user,t.qs_name,t.rzh_yesorno,
		t.invoice_type , t.dept_name deptName,t.glzt
		glzt,t.uuid,t.bdk_status,t.scan_id,t.in_account_status,t.settle_source,
		t.settlement_no,
		t.settlement_status,t.voucher_number,t.total_amount
		from t_dx_record_invoice t
		WHERE t.company = #{company} and t.invoice_date between to_date(#{kpksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{kpjsrq},'yyyy-mm-dd hh24:mi:ss')
		and t.gf_tax_no in
		<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and invoice_status in ('0','7')
		and glzt = '0'
		and lq_hzsdbs = 'N'
		and (lq_rzzt = '01' or lq_rzzt = '03')
		<!--待入账查询，特定字段固定值-->

		<!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->
		<if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
			and t.lq_hzsdbs = #{lqHzsdbs}
		</if>
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
			and t.lq_rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->

		<if
				test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
			and t.invoice_status = #{invoiceStatus}
		</if>
		<if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
			and t.qs_status = #{qszt}
		</if>
		<if test="voucherNumber != null and voucherNumber != ''">
			and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
		</if>
		<if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
			and t.rzh_yesorno = #{rzzt}
		</if>
		<!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
			and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
			and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>
		<if
				test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
			and t.rzh_type = #{fprzfs}
		</if>
		<if
				test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
			and t.auth_status = #{fprzclzt}
		</if>
		<if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
			and t.bdk_status = #{rzlx}
		</if>
		<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
			and t.xf_name like CONCAT(#{xfmc},'%')
		</if>
		<if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
			and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
		</if>
		<if test="amountMin!=null and amountMin!=''">
			and t.invoice_amount &gt;= #{amountMin}
		</if>

		<if test="amountMax!=null and amountMax!=''">
			and t.invoice_amount &lt;= #{amountMax}
		</if>
		<if test="taxAmountMin!=null and taxAmountMin!=''">
			and t.tax_amount &gt;= #{taxAmountMin}
		</if>

		<if test="taxAmountMax!=null and taxAmountMax!=''">
			and t.tax_amount &lt;= #{taxAmountMax}
		</if>

		<if test="qsr != null and qsr != '' and qsr != 'null' ">
			and t.qs_name like CONCAT(concat('%',#{qsr}),'%')
		</if>
		<if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
			and t.confirm_user like CONCAT(concat('%',#{rzhr}),'%')
		</if>
		<if test="settlementNo != null and settlementNo != ''">
			and t.settlement_no like concat(#{settlementNo},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and t.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and t.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
			and t.rzh_date between to_date(#{rzksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="skssq != null and skssq != '' and skssq != 'null' ">
			and t.rzh_belong_date = #{skssq}
		</if>
		<if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
			and t.qs_type = #{qsfs}
		</if>
		<if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
			and t.qs_date between to_date(#{qsksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
			and t.dept_id = #{businessCode}
		</if>
		<if test="businessCode==''">
			and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
		</if>
		<if test='businessCode == "99" and business!=null and business.size()>0'>
			and (t.dept_id in
			<foreach collection="business" index="index" item="item" open="(" separator="," close="">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		<if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
			and t.in_account_status = #{inAccountStatus}
		</if>
		order by t.invoice_date desc
	</select>


    <select databaseId="mysql" id="selectPreRzInvoiceHj" resultType="com.dxhy.api.model.rz.rzInvoice.TDxRecordInvoicePreRzVo" resultMap="BbfpzhcxhjResultMap" >
        select
        count(1) hjsl,
		ifnull(sum(t.invoice_amount),0) hjje,
		ifnull(sum(t.tax_amount),0) hjse
        from t_dx_record_invoice t
        WHERE t.company = #{company} and t.invoice_date between #{kpksrq} and #{kpjsrq}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>

        <!--待入账查询，特定字段固定值-->
        and invoice_status in ('0','7')
        and glzt = '0'
        and lq_hzsdbs = 'N'
        and (lq_rzzt = '01' or lq_rzzt = '03')
        <!--待入账查询，特定字段固定值-->

        <!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->
        <if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
            and t.lq_hzsdbs = #{lqHzsdbs}
        </if>
        <if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
            and t.invoice_type = '9999'
        </if>
        <!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
            and t.lq_rzzt = #{lqRzzt}
        </if>-->
        <if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
            and t.invoice_type = '9999'
        </if>
        <if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
            and t.invoice_type = '9999'
        </if>
        <!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->

        <if
                test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
            and t.invoice_status = #{invoiceStatus}
        </if>
        <if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
            and t.qs_status = #{qszt}
        </if>
        <if test="voucherNumber != null and voucherNumber != ''">
            and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
            and t.rzh_yesorno = #{rzzt}
        </if>
        <!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
            and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
            and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>
        <if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
            and t.invoice_source = #{invoiceSource}
        </if>
        <if
                test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
            and t.rzh_type = #{fprzfs}
        </if>
        <if
                test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
            and t.auth_status = #{fprzclzt}
        </if>
        <if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
            and t.bdk_status = #{rzlx}
        </if>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like CONCAT(#{xfmc},'%')
        </if>
        <if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
            and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
        </if>
        <if test="amountMin!=null and amountMin!=''">
            and t.invoice_amount &gt;= #{amountMin}
        </if>

        <if test="amountMax!=null and amountMax!=''">
            and t.invoice_amount &lt;= #{amountMax}
        </if>
        <if test="taxAmountMin!=null and taxAmountMin!=''">
            and t.tax_amount &gt;= #{taxAmountMin}
        </if>

        <if test="taxAmountMax!=null and taxAmountMax!=''">
            and t.tax_amount &lt;= #{taxAmountMax}
        </if>

        <if test="qsr != null and qsr != '' and qsr != 'null' ">
            and t.qs_name like concat('%',#{qsr},'%')
        </if>
        <if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
            and t.confirm_user like concat('%',#{rzhr},'%')
        </if>
        <if test="settlementNo != null and settlementNo != ''">
            and t.settlement_no like concat(#{settlementNo},'%')
        </if>
        <if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
            and t.glzt = #{glzt}
        </if>
        <if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
            and t.invoice_code = #{invoiceCode}
        </if>
        <if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>
        <if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
            and t.ele_invoice_no = #{eleInvoiceNo}
        </if>
        <if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
            and t.rzh_date between #{rzksrq} and #{rzjsrq}
        </if>
        <if test="skssq != null and skssq != '' and skssq != 'null' ">
            and t.rzh_belong_date = #{skssq}
        </if>
        <if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
            and t.qs_type = #{qsfs}
        </if>
        <if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
            and t.qs_date between #{qsksrq} and #{qsjsrq}
        </if>
        <if
                test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business!=null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
        <if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
            and t.in_account_status = #{inAccountStatus}
        </if>
    </select>

	<select databaseId="oracle" id="selectPreRzInvoiceHj" resultType="com.dxhy.api.model.rz.rzInvoice.TDxRecordInvoicePreRzVo" resultMap="BbfpzhcxhjResultMap" >
		select
		count(1) hjsl,
		COALESCE(sum(t.invoice_amount),0) hjje,
		COALESCE(sum(t.tax_amount),0) hjse
		from t_dx_record_invoice t
		WHERE t.company = #{company} and t.invoice_date between to_date(#{kpksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{kpjsrq},'yyyy-mm-dd hh24:mi:ss')
		and t.gf_tax_no in
		<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and invoice_status in ('0','7')
		and glzt = '0'
		and lq_hzsdbs = 'N'
		and (lq_rzzt = '01' or lq_rzzt = '03')
		<!--待入账查询，特定字段固定值-->

		<!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->
		<if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
			and t.lq_hzsdbs = #{lqHzsdbs}
		</if>
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
            and t.lq_rzzt = #{lqRzzt}
        </if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and t.invoice_type = '9999'
		</if>
		<!--待入账查询条件，当选择 lqHzsdbs lqRzyt lqRzsq 后，查不出任何数据-->

		<if
				test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
			and t.invoice_status = #{invoiceStatus}
		</if>
		<if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
			and t.qs_status = #{qszt}
		</if>
		<if test="voucherNumber != null and voucherNumber != ''">
			and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
		</if>
		<if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
			and t.rzh_yesorno = #{rzzt}
		</if>
		<!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
			and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
			and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>
		<if
				test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
			and t.rzh_type = #{fprzfs}
		</if>
		<if
				test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
			and t.auth_status = #{fprzclzt}
		</if>
		<if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
			and t.bdk_status = #{rzlx}
		</if>
		<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
			and t.xf_name like CONCAT(#{xfmc},'%')
		</if>
		<if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
			and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
		</if>
		<if test="amountMin!=null and amountMin!=''">
			and t.invoice_amount &gt;= #{amountMin}
		</if>

		<if test="amountMax!=null and amountMax!=''">
			and t.invoice_amount &lt;= #{amountMax}
		</if>
		<if test="taxAmountMin!=null and taxAmountMin!=''">
			and t.tax_amount &gt;= #{taxAmountMin}
		</if>

		<if test="taxAmountMax!=null and taxAmountMax!=''">
			and t.tax_amount &lt;= #{taxAmountMax}
		</if>

		<if test="qsr != null and qsr != '' and qsr != 'null' ">
			and t.qs_name like concat(concat('%',#{qsr}),'%')
		</if>
		<if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
			and t.confirm_user like concat(concat('%',#{rzhr}),'%')
		</if>
		<if test="settlementNo != null and settlementNo != ''">
			and t.settlement_no like concat(#{settlementNo},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and t.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and t.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
			and t.rzh_date between to_date(#{rzksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="skssq != null and skssq != '' and skssq != 'null' ">
			and t.rzh_belong_date = #{skssq}
		</if>
		<if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
			and t.qs_type = #{qsfs}
		</if>
		<if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
			and t.qs_date between to_date(#{qsksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
			and t.dept_id = #{businessCode}
		</if>
		<if test="businessCode==''">
			and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
		</if>
		<if test='businessCode == "99" and business!=null and business.size()>0'>
			and (t.dept_id in
			<foreach collection="business" index="index" item="item" open="(" separator="," close="">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		<if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
			and t.in_account_status = #{inAccountStatus}
		</if>
	</select>

	<!--入账结果查询-->
	<select databaseId="mysql" id="selectRzInvoiceResultList"   parameterType="java.util.Map"
			resultMap="BaseResultMap">
		select t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,DATE_FORMAT(t.invoice_date,'%Y-%m-%d') kprq,t.gf_tax_no
		gfsh,t.gf_name gfmc,
		t.xf_tax_no,t.xf_name,t.tax_amount,t.dk_tax_amount,t.invoice_status,t.invoice_amount,DATE_FORMAT(t.rzh_date,'%Y-%m-%d')
		rzh_date ,DATE_FORMAT(t.qs_date,'%Y-%m-%d') qs_date,t.rzh_type,t.dept_id deptId,
		t.gx_user_name,t.rzh_belong_date
		dqskssq,t.auth_status,t.qs_type,t.qs_status,t.confirm_user,t.qs_name,t.rzh_yesorno,
		t.invoice_type , t.dept_name deptName,t.glzt
		glzt,t.uuid,t.bdk_status,t.scan_id,t.in_account_status,t.settle_source,
		t.settlement_no,
		t.settlement_status,t.voucher_number,t.total_amount,
		t.lq_hzsdbs,lq_rzzt,
		rz.fprzsq,
		rz.fprz_auth_status,
		rz.fprzlx,
		rz.fprzsj,
		rz.fprzsbyy,
		rz.rzr

		from t_dx_lq_rz_invoice rz join t_dx_record_invoice t
		on rz.uuid = t.uuid
		WHERE t.company = #{company} and t.invoice_date between #{kpksrq} and #{kpjsrq}
		and t.gf_tax_no in
		<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
			and t.lq_hzsdbs = #{lqHzsdbs}
		</if>
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.fprz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
			and t.lq_rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.fprzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.fprzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->

		<if
				test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
			and t.invoice_status = #{invoiceStatus}
		</if>
		<if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
			and t.qs_status = #{qszt}
		</if>
		<if test="voucherNumber != null and voucherNumber != ''">
			and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
		</if>
		<if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
			and t.rzh_yesorno = #{rzzt}
		</if>
		<!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
			and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
			and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>
		<if
				test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
			and t.rzh_type = #{fprzfs}
		</if>
		<if
				test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
			and t.auth_status = #{fprzclzt}
		</if>
		<if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
			and t.bdk_status = #{rzlx}
		</if>
		<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
			and t.xf_name like CONCAT(#{xfmc},'%')
		</if>
		<if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
			and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
		</if>
		<if test="amountMin!=null and amountMin!=''">
			and t.invoice_amount &gt;= #{amountMin}
		</if>

		<if test="amountMax!=null and amountMax!=''">
			and t.invoice_amount &lt;= #{amountMax}
		</if>
		<if test="taxAmountMin!=null and taxAmountMin!=''">
			and t.tax_amount &gt;= #{taxAmountMin}
		</if>

		<if test="taxAmountMax!=null and taxAmountMax!=''">
			and t.tax_amount &lt;= #{taxAmountMax}
		</if>

		<if test="qsr != null and qsr != '' and qsr != 'null' ">
			and t.qs_name like concat('%',#{qsr},'%')
		</if>
		<if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
			and t.confirm_user like concat('%',#{rzhr},'%')
		</if>
		<if test="settlementNo != null and settlementNo != ''">
			and t.settlement_no like concat(#{settlementNo},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and t.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and t.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
			and t.rzh_date between #{rzksrq} and #{rzjsrq}
		</if>
		<if test="skssq != null and skssq != '' and skssq != 'null' ">
			and t.rzh_belong_date = #{skssq}
		</if>
		<if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
			and t.qs_type = #{qsfs}
		</if>
		<if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
			and t.qs_date between #{qsksrq} and #{qsjsrq}
		</if>
		<if
				test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
			and t.dept_id = #{businessCode}
		</if>
		<if test="businessCode==''">
			and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
		</if>
		<if test='businessCode == "99" and business!=null and business.size()>0'>
			and (t.dept_id in
			<foreach collection="business" index="index" item="item" open="(" separator="," close="">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		<if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
			and t.in_account_status = #{inAccountStatus}
		</if>
		order by t.invoice_date desc


	</select>

	<select databaseId="oracle" id="selectRzInvoiceResultList"   parameterType="java.util.Map"
			resultMap="BaseResultMap">
		select t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,TO_CHAR(t.invoice_date, 'yyyy-MM-dd') kprq,t.gf_tax_no
		gfsh,t.gf_name gfmc,
		t.xf_tax_no,t.xf_name,t.tax_amount,t.dk_tax_amount,t.invoice_status,t.invoice_amount,TO_CHAR(t.rzh_date, 'yyyy-MM-dd')
		rzh_date ,TO_CHAR(t.qs_date, 'yyyy-MM-dd') qs_date,t.rzh_type,t.dept_id deptId,
		t.gx_user_name,t.rzh_belong_date
		dqskssq,t.auth_status,t.qs_type,t.qs_status,t.confirm_user,t.qs_name,t.rzh_yesorno,
		t.invoice_type , t.dept_name deptName,t.glzt
		glzt,t.uuid,t.bdk_status,t.scan_id,t.in_account_status,t.settle_source,
		t.settlement_no,
		t.settlement_status,t.voucher_number,t.total_amount,
		t.lq_hzsdbs,lq_rzzt,
		rz.fprzsq,
		rz.fprz_auth_status,
		rz.fprzlx,
		rz.fprzsj,
		rz.fprzsbyy,
		rz.rzr
		from t_dx_lq_rz_invoice rz join t_dx_record_invoice t
		on rz.uuid = t.uuid
		WHERE t.company = #{company} and t.invoice_date between to_date(#{kpksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{kpjsrq},'yyyy-mm-dd hh24:mi:ss')
		and t.gf_tax_no in
		<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
			and t.lq_hzsdbs = #{lqHzsdbs}
		</if>
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.fprz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
			and t.lq_rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.fprzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.fprzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->

		<if
				test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
			and t.invoice_status = #{invoiceStatus}
		</if>
		<if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
			and t.qs_status = #{qszt}
		</if>
		<if test="voucherNumber != null and voucherNumber != ''">
			and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
		</if>
		<if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
			and t.rzh_yesorno = #{rzzt}
		</if>
		<!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
			and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
			and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>
		<if
				test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
			and t.rzh_type = #{fprzfs}
		</if>
		<if
				test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
			and t.auth_status = #{fprzclzt}
		</if>
		<if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
			and t.bdk_status = #{rzlx}
		</if>
		<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
			and t.xf_name like CONCAT(#{xfmc},'%')
		</if>
		<if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
			and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
		</if>
		<if test="amountMin!=null and amountMin!=''">
			and t.invoice_amount &gt;= #{amountMin}
		</if>

		<if test="amountMax!=null and amountMax!=''">
			and t.invoice_amount &lt;= #{amountMax}
		</if>
		<if test="taxAmountMin!=null and taxAmountMin!=''">
			and t.tax_amount &gt;= #{taxAmountMin}
		</if>

		<if test="taxAmountMax!=null and taxAmountMax!=''">
			and t.tax_amount &lt;= #{taxAmountMax}
		</if>

		<if test="qsr != null and qsr != '' and qsr != 'null' ">
			and t.qs_name like concat(concat('%',#{qsr}),'%')
		</if>
		<if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
			and t.confirm_user like concat(concat('%',#{rzhr}),'%')
		</if>
		<if test="settlementNo != null and settlementNo != ''">
			and t.settlement_no like concat(#{settlementNo},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and t.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and t.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
			and t.rzh_date between to_date(#{rzksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="skssq != null and skssq != '' and skssq != 'null' ">
			and t.rzh_belong_date = #{skssq}
		</if>
		<if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
			and t.qs_type = #{qsfs}
		</if>
		<if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
			and t.qs_date between to_date(#{qsksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
			and t.dept_id = #{businessCode}
		</if>
		<if test="businessCode==''">
			and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
		</if>
		<if test='businessCode == "99" and business!=null and business.size()>0'>
			and (t.dept_id in
			<foreach collection="business" index="index" item="item" open="(" separator="," close="">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		<if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
			and t.in_account_status = #{inAccountStatus}
		</if>
		order by t.invoice_date desc


	</select>


    <select databaseId="mysql" id="selectRzInvoiceResultHj" resultType="com.dxhy.api.model.rz.rzInvoice.TDxRecordInvoicePreRzVo" resultMap="BbfpzhcxhjResultMap" >
        select
        count(1) hjsl,
		ifnull(sum(t.invoice_amount),0) hjje,
		ifnull(sum(t.tax_amount),0) hjse

        from t_dx_lq_rz_invoice rz join t_dx_record_invoice t
        on rz.uuid = t.uuid
        WHERE t.company = #{company} and t.invoice_date between #{kpksrq} and #{kpjsrq}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>

        <!--入账结果查询条件-->
        <if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
            and t.lq_hzsdbs = #{lqHzsdbs}
        </if>
        <if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
            and rz.fprz_auth_status = #{lqRzglzt}
        </if>
        <!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
            and t.lq_rzzt = #{lqRzzt}
        </if>-->
        <if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
            and rz.fprzlx = #{lqRzyt}
        </if>
        <if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
            and rz.fprzsq = #{lqRzsq}
        </if>
        <!--入账结果查询条件-->

        <if
                test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
            and t.invoice_status = #{invoiceStatus}
        </if>
        <if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
            and t.qs_status = #{qszt}
        </if>
        <if test="voucherNumber != null and voucherNumber != ''">
            and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
            and t.rzh_yesorno = #{rzzt}
        </if>
        <!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
            and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
            and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>
        <if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
            and t.invoice_source = #{invoiceSource}
        </if>
        <if
                test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
            and t.rzh_type = #{fprzfs}
        </if>
        <if
                test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
            and t.auth_status = #{fprzclzt}
        </if>
        <if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
            and t.bdk_status = #{rzlx}
        </if>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like CONCAT(#{xfmc},'%')
        </if>
        <if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
            and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
        </if>
        <if test="amountMin!=null and amountMin!=''">
            and t.invoice_amount &gt;= #{amountMin}
        </if>

        <if test="amountMax!=null and amountMax!=''">
            and t.invoice_amount &lt;= #{amountMax}
        </if>
        <if test="taxAmountMin!=null and taxAmountMin!=''">
            and t.tax_amount &gt;= #{taxAmountMin}
        </if>

        <if test="taxAmountMax!=null and taxAmountMax!=''">
            and t.tax_amount &lt;= #{taxAmountMax}
        </if>

        <if test="qsr != null and qsr != '' and qsr != 'null' ">
            and t.qs_name like concat('%',#{qsr},'%')
        </if>
        <if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
            and t.confirm_user like concat('%',#{rzhr},'%')
        </if>
        <if test="settlementNo != null and settlementNo != ''">
            and t.settlement_no like concat(#{settlementNo},'%')
        </if>
        <if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
            and t.glzt = #{glzt}
        </if>
        <if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
            and t.invoice_code = #{invoiceCode}
        </if>
        <if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>
        <if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
            and t.ele_invoice_no = #{eleInvoiceNo}
        </if>
        <if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
            and t.rzh_date between #{rzksrq} and #{rzjsrq}
        </if>
        <if test="skssq != null and skssq != '' and skssq != 'null' ">
            and t.rzh_belong_date = #{skssq}
        </if>
        <if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
            and t.qs_type = #{qsfs}
        </if>
        <if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
            and t.qs_date between #{qsksrq} and #{qsjsrq}
        </if>
        <if
                test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business!=null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
        <if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
            and t.in_account_status = #{inAccountStatus}
        </if>
    </select>

	<select databaseId="oracle" id="selectRzInvoiceResultHj" resultType="com.dxhy.api.model.rz.rzInvoice.TDxRecordInvoicePreRzVo" resultMap="BbfpzhcxhjResultMap" >
		select
		count(1) hjsl,
		COALESCE(sum(t.invoice_amount),0) hjje,
		COALESCE(sum(t.tax_amount),0) hjse

		from t_dx_lq_rz_invoice rz join t_dx_record_invoice t
		on rz.uuid = t.uuid
		WHERE t.company = #{company} and t.invoice_date between to_date(#{kpksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{kpjsrq},'yyyy-mm-dd hh24:mi:ss')
		and t.gf_tax_no in
		<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqHzsdbs != null and lqHzsdbs != '' and lqHzsdbs != 'null' ">
			and t.lq_hzsdbs = #{lqHzsdbs}
		</if>
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.fprz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
            and t.lq_rzzt = #{lqRzzt}
        </if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.fprzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.fprzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->

		<if
				test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
			and t.invoice_status = #{invoiceStatus}
		</if>
		<if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
			and t.qs_status = #{qszt}
		</if>
		<if test="voucherNumber != null and voucherNumber != ''">
			and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
		</if>
		<if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '99'">
			and t.rzh_yesorno = #{rzzt}
		</if>
		<!--<if
                test="invoiceType != null and invoiceType != '' and invoiceType != 'null'  and invoiceType != '99'">
            and t.invoice_type = #{invoiceType}
        </if>-->
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
			and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '32' ">
			and t.invoice_type = #{invoiceType} and t.lq_tdyslxDm!='08'
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' and invoiceType != '32' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>
		<if
				test="fprzfs != null and fprzfs != '' and fprzfs != 'null' and fprzfs != '99'">
			and t.rzh_type = #{fprzfs}
		</if>
		<if
				test="fprzclzt != null and fprzclzt != '' and fprzclzt != 'null' and fprzclzt != '99'">
			and t.auth_status = #{fprzclzt}
		</if>
		<if test="rzlx != null and rzlx != '' and rzlx != 'null' and rzlx != '99'">
			and t.bdk_status = #{rzlx}
		</if>
		<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
			and t.xf_name like CONCAT(#{xfmc},'%')
		</if>
		<if test="xfsh != null and xfsh != '' and xfsh != 'null' ">
			and SUBSTR(t.xf_tax_no , -6) = #{xfsh}
		</if>
		<if test="amountMin!=null and amountMin!=''">
			and t.invoice_amount &gt;= #{amountMin}
		</if>

		<if test="amountMax!=null and amountMax!=''">
			and t.invoice_amount &lt;= #{amountMax}
		</if>
		<if test="taxAmountMin!=null and taxAmountMin!=''">
			and t.tax_amount &gt;= #{taxAmountMin}
		</if>

		<if test="taxAmountMax!=null and taxAmountMax!=''">
			and t.tax_amount &lt;= #{taxAmountMax}
		</if>

		<if test="qsr != null and qsr != '' and qsr != 'null' ">
			and t.qs_name like concat(concat('%',#{qsr}),'%')
		</if>
		<if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
			and t.confirm_user like concat(concat('%',#{rzhr}),'%')
		</if>
		<if test="settlementNo != null and settlementNo != ''">
			and t.settlement_no like concat(#{settlementNo},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if test="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and t.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and t.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="rzksrq != null and rzjsrq != null and rzksrq != '' and rzjsrq != ''">
			and t.rzh_date between to_date(#{rzksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="skssq != null and skssq != '' and skssq != 'null' ">
			and t.rzh_belong_date = #{skssq}
		</if>
		<if test="qsfs != null and qsfs != '' and qsfs != 'null' and qsfs != '99'">
			and t.qs_type = #{qsfs}
		</if>
		<if test="qsksrq != null and qsjsrq != null and qsksrq != '' and qsjsrq != ''">
			and t.qs_date between to_date(#{qsksrq},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsjsrq},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
			and t.dept_id = #{businessCode}
		</if>
		<if test="businessCode==''">
			and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
		</if>
		<if test='businessCode == "99" and business!=null and business.size()>0'>
			and (t.dept_id in
			<foreach collection="business" index="index" item="item" open="(" separator="," close="">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		<if test='inAccountStatus!=null and inAccountStatus != "" and inAccountStatus != "99"'>
			and t.in_account_status = #{inAccountStatus}
		</if>
	</select>


</mapper>