<?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.RzRecordCustomDao" >

	<resultMap id="BaseResultMap"
			   type="com.dxhy.api.model.rz.rzCustom.JkszhcxRespVO">
		<result column="customs_code" property="customsCode"/>
		<result column="fill_in_date" property="fillInDate"/>
		<result column="gf_tax_no" property="gfTaxNo"/>
		<result column="gf_name" property="gfName"/>
		<result column="tax_amount" property="taxAmount"/>
		<result column="yx_tax_amount" property="yxTaxAmount"/>
		<result column="audit_status" property="auditStatus"/>
		<result column="apply_check" property="applyCheck"/>
		<result column="check_status" property="checkStatus"/>
		<result column="qs_status" property="qsStatus"/>
		<result column="qs_date" property="qsDate"/>
		<result column="qs_type" property="qsType"/>
		<result column="qs_user" property="qsUser"/>
		<result column="rzh_date" property="rzhDate"/>
		<result column="rzh_yesorno" property="rzhYesorno"/>
		<result column="auth_status" property="authStatus"/>
		<result column="bdk_status" property="bdkStatus"/>
		<result column="confirm_user" property="confirmUser"/>
		<result column="rzh_belong_date" property="rzhBelongDate"/>
		<result column="glzt" property="glzt"/>
		<result column="customs_scan_id" property="customsScanId"/>
		<result column="businessName" property="businessName"/>
		<result column="rzzt" property="rzzt"/>

		<result column="jksrzsq" property="jksrzsq" jdbcType="VARCHAR"/>
		<result column="jksrz_auth_status" property="jksrzAuthStatus" jdbcType="VARCHAR" />
		<result column="jksrzlx" property="jksrzlx" jdbcType="VARCHAR" />
		<result column="jksrzsj" property="jksrzsj" jdbcType="VARCHAR" />
		<result column="jksrzsbyy" property="jksrzsbyy" jdbcType="VARCHAR" />
		<result column="rzr" property="rzr" jdbcType="VARCHAR" />
	</resultMap>

	<resultMap id="HjResultMap" type="java.util.Map">
		<result column="hjsl"  property="hjsl"  javaType="Long"/>
		<result column="hjse"  property="hjse" />
	</resultMap>

	<select databaseId="mysql" id="preRzCustomHj" parameterType="java.util.Map" resultMap="HjResultMap">
		select
		count(1) hjsl,
		ifnull(sum(t.tax_amount),0) hjse
		from t_dx_customs_record t
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and glzt = '0'
		and (rzzt = '01' or rzzt = '03')
		<!--待入账查询，特定字段固定值-->

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



		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT('%',#{gfName},'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between #{fillInStartDate} and #{fillInEndDate}
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT('%',#{confirmUser},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between #{qsDateStartDate} and #{qsDateEndDate}
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between #{rzhStartDate} and #{rzhEndDate}
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
	</select>

	<select databaseId="oracle" id="preRzCustomHj" parameterType="java.util.Map" resultMap="HjResultMap">
		select
		count(1) hjsl,
		COALESCE(sum(t.tax_amount),0) hjse
		from t_dx_customs_record t
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and glzt = '0'
		and (rzzt = '01' or rzzt = '03')
		<!--待入账查询，特定字段固定值-->

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



		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT(CONCAT('%',#{gfName}),'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between to_date(#{fillInStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{fillInEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT(CONCAT('%',#{confirmUser}),'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between to_date(#{qsDateStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsDateEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between to_date(#{rzhStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzhEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
	</select>




	<select databaseId="mysql" id="preRzCustomList" parameterType="java.util.Map" resultMap="BaseResultMap">
		select
		t.id,t.customs_code,DATE_FORMAT(t.fill_in_date,'%Y-%m-%d')
		fill_in_date,t.gf_tax_no,t.gf_name,t.tax_amount,t.yx_tax_amount,t.audit_status,t.apply_check,t.check_status,t.qs_status,
		DATE_FORMAT(t.qs_date,'%Y-%m-%d') qs_date,t.qs_type,t.qs_user,DATE_FORMAT(t.rzh_date,'%Y-%m-%d')
		rzh_date, t.rzh_yesorno,t.auth_status,t.bdk_status,t.confirm_user,t.rzh_belong_date,t.glzt,
		t.customs_scan_id,t.dept_name businessName
		from t_dx_customs_record t
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and glzt = '0'
		and (rzzt = '01' or rzzt = '03')
		<!--待入账查询，特定字段固定值-->

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


		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT('%',#{gfName},'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between #{fillInStartDate} and #{fillInEndDate}
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT('%',#{confirmUser},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between #{qsDateStartDate} and #{qsDateEndDate}
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between #{rzhStartDate} and #{rzhEndDate}
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		order by t.fill_in_date desc
	</select>

	<select databaseId="oracle" id="preRzCustomList" parameterType="java.util.Map" resultMap="BaseResultMap">
		select
		t.id,t.customs_code,TO_CHAR(t.fill_in_date, 'yyyy-MM-dd')
		fill_in_date,t.gf_tax_no,t.gf_name,t.tax_amount,t.yx_tax_amount,t.audit_status,t.apply_check,t.check_status,t.qs_status,
		TO_CHAR(t.qs_date, 'yyyy-MM-dd') qs_date,t.qs_type,t.qs_user,TO_CHAR(t.rzh_date, 'yyyy-MM-dd')
		rzh_date, t.rzh_yesorno,t.auth_status,t.bdk_status,t.confirm_user,t.rzh_belong_date,t.glzt,
		t.customs_scan_id,t.dept_name businessName
		from t_dx_customs_record t
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--待入账查询，特定字段固定值-->
		and glzt = '0'
		and (rzzt = '01' or rzzt = '03')
		<!--待入账查询，特定字段固定值-->

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


		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT(CONCAT('%',#{gfName}),'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between to_date(#{fillInStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{fillInEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT(CONCAT('%',#{confirmUser}),'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between to_date(#{qsDateStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsDateEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between to_date(#{rzhStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzhEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		order by t.fill_in_date desc
	</select>


	<select databaseId="mysql" id="rzCustomResultHj" parameterType="java.util.Map" resultMap="HjResultMap">
		select
		count(1) hjsl,
		ifnull(sum(t.tax_amount),0) hjse
		from t_dx_customs_record t  join t_dx_lq_rz_custom rz
		on t.customs_code = rz.customs_code
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.jksrz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
			and t.rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.jksrzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.jksrzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->


		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT('%',#{gfName},'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between #{fillInStartDate} and #{fillInEndDate}
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT('%',#{confirmUser},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between #{qsDateStartDate} and #{qsDateEndDate}
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between #{rzhStartDate} and #{rzhEndDate}
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
	</select>

	<select databaseId="oracle" id="rzCustomResultHj" parameterType="java.util.Map" resultMap="HjResultMap">
		select
		count(1) hjsl,
		COALESCE(sum(t.tax_amount),0) hjse
		from t_dx_customs_record t  join t_dx_lq_rz_custom rz
		on t.customs_code = rz.customs_code
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.jksrz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt != 'null' ">
			and t.rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.jksrzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.jksrzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->


		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT(CONCAT('%',#{gfName}),'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between to_date(#{fillInStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{fillInEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT(CONCAT('%',#{confirmUser}),'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between to_date(#{qsDateStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{qsDateEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between to_date(#{rzhStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{rzhEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
	</select>



	<select databaseId="mysql" id="rzCustomResultList" parameterType="java.util.Map" resultMap="BaseResultMap">
		select
		t.id,t.customs_code,DATE_FORMAT(t.fill_in_date,'%Y-%m-%d')
		fill_in_date,t.gf_tax_no,t.gf_name,t.tax_amount,t.yx_tax_amount,t.audit_status,t.apply_check,t.check_status,t.qs_status,
		DATE_FORMAT(t.qs_date,'%Y-%m-%d') qs_date,t.qs_type,t.qs_user,DATE_FORMAT(t.rzh_date,'%Y-%m-%d')
		rzh_date, t.rzh_yesorno,t.auth_status,t.bdk_status,t.confirm_user,t.rzh_belong_date,t.glzt,
		t.customs_scan_id,t.dept_name businessName,
		t.rzzt,
		rz.jksrzsq,
		rz.jksrz_auth_status,
		rz.jksrzlx,
		rz.jksrzsj,
		rz.jksrzsbyy,
		rz.rzr

		from t_dx_customs_record t  join t_dx_lq_rz_custom rz
		on t.customs_code = rz.customs_code
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.jksrz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt == '1' ">
			and t.rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.jksrzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.jksrzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->


		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT('%',#{gfName},'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between #{fillInStartDate} and #{fillInEndDate}
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT('%',#{confirmUser},'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between #{qsDateStartDate} and #{qsDateEndDate}
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between #{rzhStartDate} and #{rzhEndDate}
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		order by t.fill_in_date desc
	</select>

	<select databaseId="oracle" id="rzCustomResultList" parameterType="java.util.Map" resultMap="BaseResultMap">
		select
		t.id,t.customs_code,TO_CHAR(t.fill_in_date, 'yyyy-MM-dd')
		fill_in_date,t.gf_tax_no,t.gf_name,t.tax_amount,t.yx_tax_amount,t.audit_status,t.apply_check,t.check_status,t.qs_status,
		TO_CHAR(t.qs_date, 'yyyy-MM-dd') qs_date,t.qs_type,t.qs_user,TO_CHAR(t.rzh_date, 'yyyy-MM-dd')
		rzh_date, t.rzh_yesorno,t.auth_status,t.bdk_status,t.confirm_user,t.rzh_belong_date,t.glzt,
		t.customs_scan_id,t.dept_name businessName,
		t.rzzt,
		rz.jksrzsq,
		rz.jksrz_auth_status,
		rz.jksrzlx,
		rz.jksrzsj,
		rz.jksrzsbyy,
		rz.rzr

		from t_dx_customs_record t  join t_dx_lq_rz_custom rz
		on t.customs_code = rz.customs_code
		where export_mark = '0' and t.gf_tax_no in
		<foreach close=")" collection="gfsh" index="index" item="item" open="(" separator=",">
			#{item}
		</foreach>

		<!--入账结果查询条件-->
		<if test="lqRzglzt != null and lqRzglzt != '' and lqRzglzt != 'null' ">
			and rz.jksrz_auth_status = #{lqRzglzt}
		</if>
		<!--<if test="lqRzzt != null and lqRzzt != '' and lqRzzt == '1' ">
			and t.rzzt = #{lqRzzt}
		</if>-->
		<if test="lqRzyt != null and lqRzyt != '' and lqRzyt != 'null' ">
			and rz.jksrzlx = #{lqRzyt}
		</if>
		<if test="lqRzsq != null and lqRzsq != '' and lqRzsq != 'null' ">
			and rz.jksrzsq = #{lqRzsq}
		</if>
		<!--入账结果查询条件-->


		<if test="gfName != null and gfName != '' and gfName != 'null'">
			and t.gf_name like CONCAT(CONCAT('%',#{gfName}),'%')
		</if>
		<if test="customsCode != null and customsCode != '' and customsCode != 'null'">
			and t.customs_code = #{customsCode}
		</if>
		<if
				test="fillInStartDate != null and fillInEndDate != null and fillInStartDate != '' and fillInEndDate != ''">
			and t.fill_in_date between to_date(#{fillInStartDate},'yyyy-mm-dd hh24:mi:ss') and to_date(#{fillInEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="taxAmount != null and taxAmount != '' and taxAmount != 'null'">
			and t.tax_amount = #{taxAmount}+0
		</if>
		<if test="qsStatus != null and qsStatus != '' and qsStatus != 'null' and qsStatus != '99'">
			and t.qs_status = #{qsStatus}
		</if>
		<if
				test="rzhYesorno != null and rzhYesorno != '' and rzhYesorno != 'null' and rzhYesorno != '99'">
			and t.rzh_yesorno = #{rzhYesorno}
		</if>
		<if test="bdkStatus != null and bdkStatus != '' and bdkStatus != 'null' and bdkStatus != '99'">
			and t.bdk_status = #{bdkStatus}
		</if>
		<if test="confirmUser != null and confirmUser != '' and confirmUser != 'null' ">
			and t.confirm_user like CONCAT(CONCAT('%',#{confirmUser}),'%')
		</if>
		<if test="glzt != null and glzt != '' and glzt != 'null' and glzt != '99'">
			and t.glzt = #{glzt}
		</if>
		<if
				test="auditStatus != null and auditStatus != '' and auditStatus != 'null' and auditStatus != '99'">
			and t.audit_status = #{auditStatus}
		</if>
		<if
				test="applyCheck != null and applyCheck != '' and applyCheck != 'null' and applyCheck != '99'">
			and t.apply_check = #{applyCheck}
		</if>
		<if
				test="checkStatus != null and checkStatus != '' and checkStatus != 'null' and checkStatus != '99'">
			and t.check_status = #{checkStatus}
		</if>
		<if
				test="qsDateStartDate != null and qsDateEndDate != null and qsDateStartDate != '' and qsDateEndDate != ''">
			and t.qs_date between to_date(#{qsDateStartDate},'yyyy-mm-dd hh24:mi:ss')  and to_date(#{qsDateEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if
				test="rzhStartDate != null and rzhEndDate != null and rzhStartDate != '' and rzhEndDate != ''">
			and t.rzh_date between to_date(#{rzhStartDate},'yyyy-mm-dd hh24:mi:ss')  and to_date(#{rzhEndDate},'yyyy-mm-dd hh24:mi:ss')
		</if>
		<if test="rzhBelongDate != null and rzhBelongDate != '' and rzhBelongDate != 'null' ">
			and t.rzh_belong_date = #{rzhBelongDate}
		</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 close="" collection="business" index="index" item="item" open="(" separator=",">
				#{item.businessCode}
			</foreach>
			) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
		</if>
		order by t.fill_in_date desc
	</select>
</mapper>