<?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.ncpInvoice.dao.NcpRecordInvoiceDao" >

	<resultMap id="BaseResultMap"
			   type="com.dxhy.api.model.ncp.ncpInvoice.TDxRecordInvoiceNcpVo">
		<result column="invoice_code" property="invoiceCode"/>
		<result column="invoice_no" property="invoiceNo"/>
		<result column="eleInvoiceNo" property="eleInvoiceNo"/>
		<result column="kprq" property="invoiceDate"/>
		<result column="kprqDate" property="invoiceDateDate"/>
		<result column="invoice_type" property="invoiceType"/>
		<result column="lq_ckznxzmbh" property="lqCkznxzmbh"/>
		<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="lq_hzsdbs" property="lqHzsdbs"/>

		<result column="ncpfpcllx" property="ncpfpcllx" jdbcType="VARCHAR" />
		<result column="dqsqqrclzt" property="dqsqqrclzt" jdbcType="VARCHAR" />
		<result column="jdqrzt" property="jdqrzt" jdbcType="VARCHAR" />
		<result column="jdqrlx" property="jdqrlx" jdbcType="VARCHAR" />
		<result column="ncpbfje" property="ncpbfje" jdbcType="VARCHAR" />
		<result column="ncpbfse" property="ncpbfse" jdbcType="VARCHAR" />
		<result column="yxdkse" property="yxdkse" jdbcType="VARCHAR" />
		<result column="kjjkcse" property="kjjkcse" jdbcType="VARCHAR" />
		<result column="sykjjkcse" property="sykjjkcse" jdbcType="VARCHAR" />
		<result column="qrsbyy" property="qrsbyy" jdbcType="VARCHAR" />
		<result column="qrsj" property="qrsj" jdbcType="VARCHAR" />
		<result column="qrr" property="qrr" jdbcType="VARCHAR" />
	</resultMap>

    <resultMap id="BbfpzhcxhjResultMap"
               type="com.dxhy.api.model.ncp.ncpInvoice.TDxRecordInvoiceNcpVo">
        <result column="hjsl" property="id"/>
        <result column="hjje" property="invoiceAmount"/>
        <result column="hjse" property="taxAmount"/>
    </resultMap>


	<select databaseId="mysql" id="selectNcpXsInvoiceHj" resultType="com.dxhy.api.model.ncp.ncpInvoice.TDxRecordInvoiceNcpVo" resultMap="BbfpzhcxhjResultMap" >
		select
		count(1) hjsl,sum(t.invoice_amount) hjje,sum(t.tax_amount) hjse
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		WHERE t.company = #{company} and ncp.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="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and ncp.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and ncp.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<!--申请确认状态-->
		<if test="dqsqqrclzt != null and dqsqqrclzt != '' and dqsqqrclzt != 'null' and dqsqqrclzt != '99'">
			and ncp.dqsqqrclzt = #{dqsqqrclzt}
		</if>


		<!--申请确认类型-->
		<if test="ncpfpcllx != null and ncpfpcllx != '' and ncpfpcllx != 'null' and ncpfpcllx != '99'">
			and ncp.ncpfpcllx = #{ncpfpcllx}
		</if>

		<!--发票确认状态-->
		<if test="jdqrzt != null and jdqrzt != '' and jdqrzt != 'null' and jdqrzt != '99'">
			and ncp.jdqrzt = #{jdqrzt}
		</if>

		<!--发票确认类型-->
		<if test="jdqrlx != null and jdqrlx != '' and jdqrlx != 'null' and jdqrlx != '99'">
			and ncp.jdqrlx = #{jdqrlx}
		</if>


		<if test="uuids != null and uuids.size() > 0">
			and ncp.uuid in
			<foreach collection="uuids" index="index" item="item"
					 open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>

		<!--查询页类型 区分是农产品 ：销售普票 还是 3%专票
		销售普票   0
        3%专票     1
		-->
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="0"'>
			and ncp.ncpfpcllx in ('1','13','14','15')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="1"'>
			and ncp.ncpfpcllx in ('2','16','17')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="2"'>
			<!--and ncp.ncpfpcllx = '3' and ncp.xf_tax_no like '%DK%' and t.invoice_status in ('0','7') and t.lq_hzsdbs = 'N' and t.glzt = '0' and t.auth_status in ('0','5','6')-->
			and ncp.ncpfpcllx = '3'
		</if>

		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>

		<if test="ncpQrsjKs != null and ncpQrsjKs != '' and ncpQrsjKs != 'null' ">
			and ncp.qrsj &gt;= #{ncpQrsjKs}
		</if>
		<if test="ncpQrsjJs != null and ncpQrsjJs != '' and ncpQrsjJs != 'null' ">
			and ncp.qrsj &lt;= #{ncpQrsjJs}
		</if>

	</select>

	<select databaseId="oracle" id="selectNcpXsInvoiceHj" resultType="com.dxhy.api.model.ncp.ncpInvoice.TDxRecordInvoiceNcpVo" resultMap="BbfpzhcxhjResultMap" >
		select
		count(1) hjsl,sum(t.invoice_amount) hjje,sum(t.tax_amount) hjse
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		WHERE t.company = #{company} and ncp.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="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and ncp.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and ncp.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<!--申请确认状态-->
		<if test="dqsqqrclzt != null and dqsqqrclzt != '' and dqsqqrclzt != 'null' and dqsqqrclzt != '99'">
			and ncp.dqsqqrclzt = #{dqsqqrclzt}
		</if>


		<!--申请确认类型-->
		<if test="ncpfpcllx != null and ncpfpcllx != '' and ncpfpcllx != 'null' and ncpfpcllx != '99'">
			and ncp.ncpfpcllx = #{ncpfpcllx}
		</if>

		<!--发票确认状态-->
		<if test="jdqrzt != null and jdqrzt != '' and jdqrzt != 'null' and jdqrzt != '99'">
			and ncp.jdqrzt = #{jdqrzt}
		</if>

		<!--发票确认类型-->
		<if test="jdqrlx != null and jdqrlx != '' and jdqrlx != 'null' and jdqrlx != '99'">
			and ncp.jdqrlx = #{jdqrlx}
		</if>


		<if test="uuids != null and uuids.size() > 0">
			and ncp.uuid in
			<foreach collection="uuids" index="index" item="item"
					 open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>

		<!--查询页类型 区分是农产品 ：销售普票 还是 3%专票
		销售普票   0
        3%专票     1
		-->
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="0"'>
			and ncp.ncpfpcllx in ('1','13','14','15')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="1"'>
			and ncp.ncpfpcllx in ('2','16','17')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="2"'>
			<!--and ncp.ncpfpcllx = '3' and ncp.xf_tax_no like '%DK%' and t.invoice_status in ('0','7') and t.lq_hzsdbs = 'N' and t.glzt = '0' and t.auth_status in ('0','5','6')-->
			and ncp.ncpfpcllx = '3'
		</if>

		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>

		<if test="ncpQrsjKs != null and ncpQrsjKs != '' and ncpQrsjKs != 'null' ">
			and ncp.qrsj &gt;= to_date(#{ncpQrsjKs},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="ncpQrsjJs != null and ncpQrsjJs != '' and ncpQrsjJs != 'null' ">
			and ncp.qrsj &lt;= to_date(#{ncpQrsjJs},'yyyy-mm-dd hh24:mi:ss')
		</if>

	</select>

	<!--待入账发票查询-->
	<select databaseId="mysql" id="selectNcpXsInvoiceList"  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.invoice_date kprqDate,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,

		ncp.ncpfpcllx,ncp.dqsqqrclzt,ncp.jdqrzt,ncp.jdqrlx,ncp.ncpbfje,ncp.ncpbfse,ncp.kjjkcse,ncp.sykjjkcse,
		ncp.yxdkse,ncp.qrsbyy,DATE_FORMAT(ncp.qrsj,'%Y-%m-%d %H:%i:%s') qrsj,qrr
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		WHERE t.company = #{company} and ncp.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="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and ncp.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and ncp.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<!--申请确认状态-->
		<if test="dqsqqrclzt != null and dqsqqrclzt != '' and dqsqqrclzt != 'null' and dqsqqrclzt != '99'">
			and ncp.dqsqqrclzt = #{dqsqqrclzt}
		</if>


		<!--申请确认类型-->
		<if test="ncpfpcllx != null and ncpfpcllx != '' and ncpfpcllx != 'null' and ncpfpcllx != '99'">
			and ncp.ncpfpcllx = #{ncpfpcllx}
		</if>

		<!--发票确认状态-->
		<if test="jdqrzt != null and jdqrzt != '' and jdqrzt != 'null' and jdqrzt != '99'">
			and ncp.jdqrzt = #{jdqrzt}
		</if>

		<!--发票确认类型-->
		<if test="jdqrlx != null and jdqrlx != '' and jdqrlx != 'null' and jdqrlx != '99'">
			and ncp.jdqrlx = #{jdqrlx}
		</if>


		<if test="uuids != null and uuids.size() > 0">
			and ncp.uuid in
			<foreach collection="uuids" index="index" item="item"
					 open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>

		<!--查询页类型 区分是农产品 ：销售普票 还是 3%专票
		销售普票   0
        3%专票     1
		-->
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="0"'>
			and ncp.ncpfpcllx in ('1','13','14','15')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="1"'>
			and ncp.ncpfpcllx in ('2','16','17')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="2"'>
 			<!--and ncp.ncpfpcllx = '3' and ncp.xf_tax_no like '%DK%' and t.invoice_status in ('0','7') and t.lq_hzsdbs = 'N' and t.glzt = '0' and t.auth_status in ('0','5','6')-->
			and ncp.ncpfpcllx = '3'
		</if>

		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>

		<if test="ncpQrsjKs != null and ncpQrsjKs != '' and ncpQrsjKs != 'null' ">
			and ncp.qrsj &gt;= #{ncpQrsjKs}
		</if>
		<if test="ncpQrsjJs != null and ncpQrsjJs != '' and ncpQrsjJs != 'null' ">
			and ncp.qrsj &lt;= #{ncpQrsjJs}
		</if>

		order by t.invoice_date desc
	</select>

	<select databaseId="oracle" id="selectNcpXsInvoiceList"  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.invoice_date kprqDate,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,

		ncp.ncpfpcllx,ncp.dqsqqrclzt,ncp.jdqrzt,ncp.jdqrlx,ncp.ncpbfje,ncp.ncpbfse,ncp.kjjkcse,ncp.sykjjkcse,
		ncp.yxdkse,ncp.qrsbyy,TO_CHAR(ncp.qrsj, 'yyyy-MM-dd') qrsj,qrr
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		WHERE t.company = #{company} and ncp.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="invoiceCode != null and invoiceCode != '' and invoiceCode != 'null' ">
			and ncp.invoice_code = #{invoiceCode}
		</if>
		<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
			and ncp.invoice_no = #{invoiceNo}
		</if>
		<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
			and t.ele_invoice_no = #{eleInvoiceNo}
		</if>
		<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '99'">
			and t.invoice_type = #{invoiceType}
		</if>
		<if test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<!--申请确认状态-->
		<if test="dqsqqrclzt != null and dqsqqrclzt != '' and dqsqqrclzt != 'null' and dqsqqrclzt != '99'">
			and ncp.dqsqqrclzt = #{dqsqqrclzt}
		</if>


		<!--申请确认类型-->
		<if test="ncpfpcllx != null and ncpfpcllx != '' and ncpfpcllx != 'null' and ncpfpcllx != '99'">
			and ncp.ncpfpcllx = #{ncpfpcllx}
		</if>

		<!--发票确认状态-->
		<if test="jdqrzt != null and jdqrzt != '' and jdqrzt != 'null' and jdqrzt != '99'">
			and ncp.jdqrzt = #{jdqrzt}
		</if>

		<!--发票确认类型-->
		<if test="jdqrlx != null and jdqrlx != '' and jdqrlx != 'null' and jdqrlx != '99'">
			and ncp.jdqrlx = #{jdqrlx}
		</if>


		<if test="uuids != null and uuids.size() > 0">
			and ncp.uuid in
			<foreach collection="uuids" index="index" item="item"
					 open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>

		<!--查询页类型 区分是农产品 ：销售普票 还是 3%专票
		销售普票   0
        3%专票     1
		-->
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="0"'>
			and ncp.ncpfpcllx in ('1','13','14','15')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="1"'>
			and ncp.ncpfpcllx in ('2','16','17')
		</if>
		<if test='searchPageType!=null and searchPageType!="" and searchPageType!="null" and searchPageType=="2"'>
			<!--and ncp.ncpfpcllx = '3' and ncp.xf_tax_no like '%DK%' and t.invoice_status in ('0','7') and t.lq_hzsdbs = 'N' and t.glzt = '0' and t.auth_status in ('0','5','6')-->
			and ncp.ncpfpcllx = '3'
		</if>

		<if test="invoiceSource != null and invoiceSource != '' and invoiceSource != 'null' and invoiceSource != '99' ">
			and t.invoice_source = #{invoiceSource}
		</if>

		<if test="ncpQrsjKs != null and ncpQrsjKs != '' and ncpQrsjKs != 'null' ">
			and ncp.qrsj &gt;= to_date(#{ncpQrsjKs},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="ncpQrsjJs != null and ncpQrsjJs != '' and ncpQrsjJs != 'null' ">
			and ncp.qrsj &lt;= to_date(#{ncpQrsjJs},'yyyy-mm-dd hh24:mi:ss')
		</if>

		order by t.invoice_date desc
	</select>

	<!--查找发票和农产品关联的信息，通过uuid-->
    <select id="selectNcpXsInvoiceByUuid"
			resultMap="BaseResultMap">
			select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,DATE_FORMAT(t.invoice_date,'%Y-%m-%d') kprq,t.invoice_date kprqDate,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_ckznxzmbh,
		ncp.ncpfpcllx,ncp.dqsqqrclzt,ncp.ncpbfje,ncp.yxdkse,ncp.kjjkcse,ncp.sykjjkcse,
		ncp.qrsbyy,DATE_FORMAT(ncp.qrsj,'%Y-%m-%d %H:%i:%s') qrsj,qrr
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		where ncp.uuid = #{uuid}
	</select>

	<select id="selectNcpXsInvoiceByUuid" resultMap="BaseResultMap" databaseId="oracle">
			select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,to_char(t.invoice_date,'yyyy-mm-dd') kprq,t.invoice_date kprqDate,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_ckznxzmbh,
		ncp.ncpfpcllx,ncp.dqsqqrclzt,ncp.ncpbfje,ncp.yxdkse,ncp.kjjkcse,ncp.sykjjkcse,
		ncp.qrsbyy,to_char(ncp.qrsj,'yyyy-mm-dd hh24:mi:ss') qrsj,qrr
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		where ncp.uuid = #{uuid}
	</select>

	<!--查找发票底账表的信息，通过uuid-->
	<select id="selectRecordInvoiceByUuid"
			resultMap="BaseResultMap">
			select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,DATE_FORMAT(t.invoice_date,'%Y-%m-%d') kprq,t.invoice_date kprqDate,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_ckznxzmbh,t.lq_hzsdbs
		from t_dx_record_invoice t
		where t.uuid = #{uuid}
	</select>

	<select id="selectRecordInvoiceByUuid" resultMap="BaseResultMap" databaseId="oracle">
			select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,to_char(t.invoice_date,'yyyy-mm-dd') kprq,t.invoice_date kprqDate,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_ckznxzmbh,t.lq_hzsdbs
		from t_dx_record_invoice t
		where t.uuid = #{uuid}
	</select>

	<!--通过uuid批量查找-->
	<select id="selectNcpXsInvoiceByUuids"
			resultMap="BaseResultMap">
			select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,DATE_FORMAT(t.invoice_date,'%Y-%m-%d') kprq,t.invoice_date kprqDate,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,
		ncp.ncpfpcllx,ncp.dqsqqrclzt,ncp.ncpbfje,ncp.yxdkse,ncp.kjjkcse,ncp.sykjjkcse,
		ncp.qrsbyy,DATE_FORMAT(ncp.qrsj,'%Y-%m-%d %H:%i:%s') qrsj,qrr
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		where 1=1
		<if test="uuids != null and uuids.size() > 0">
			and ncp.uuid in
			<foreach collection="uuids" index="index" item="item"
					 open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<select id="selectNcpXsInvoiceByUuids" resultMap="BaseResultMap" databaseId="oracle">
		select
		t.invoice_code,t.invoice_no,t.ele_invoice_no eleInvoiceNo,to_char(t.invoice_date,'yyyy-mm-dd') kprq,t.invoice_date kprqDate,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,
		ncp.ncpfpcllx,ncp.dqsqqrclzt,ncp.ncpbfje,ncp.yxdkse,ncp.kjjkcse,ncp.sykjjkcse,
		ncp.qrsbyy,to_char(ncp.qrsj,'yyyy-mm-dd hh24:mi:ss') qrsj,qrr
		from t_dx_invoice_ncp ncp left join t_dx_record_invoice t on t.uuid = ncp.uuid
		where 1=1
		<if test="uuids != null and uuids.size() > 0">
			and ncp.uuid in
			<foreach collection="uuids" index="index" item="item"
				open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

</mapper>