<?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.core.dao.CustomsCollectDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dxhy.core.entity.TDxCustomsRecord">
        <id column="id" property="id"/>
        <result column="gf_name" property="gfName"/>
        <result column="gf_tax_no" property="gfTaxNo"/>
        <result column="customs_code" property="customsCode"/>
        <result column="payer_one_taxno" property="payerOneTaxno"/>
        <result column="payer_one_name" property="payerOneName"/>
        <result column="payer_two_taxno" property="payerTwoTaxno"/>
        <result column="payer_two_name" property="payerTwoName"/>
        <result column="fill_in_date" property="fillInDate"/>
        <result column="tax_amount" property="taxAmount"/>
        <result column="yx_tax_amount" property="yxTaxAmount"/>
        <result column="import_port_code" property="importPortCode"/>
        <result column="income_office" property="incomeOffice"/>
        <result column="applicant_code" property="applicantCode"/>
        <result column="bill_code" property="billCode"/>
        <result column="mode_type" property="modeType"/>
        <result column="budget_code" property="budgetCode"/>
        <result column="treasury_code" property="treasuryCode"/>
        <result column="contract_code" property="contractCode"/>
        <result column="means_transport" property="meansTransport"/>
        <result column="payment_period" property="paymentPeriod"/>
        <result column="delivery_code" property="deliveryCode"/>
        <result column="data_sources" property="dataSources"/>
        <result column="create_date" property="createDate"/>
        <result column="update_date" property="updateDate"/>
        <result column="data_type" property="dataType"/>
        <result column="collect_upload_status" property="collectUploadStatus"/>
        <result column="audit_status" property="auditStatus"/>
        <result column="apply_check" property="applyCheck"/>
        <result column="fail_reason" property="failReason"/>
        <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_belong_date" property="rzhBelongDate"/>
        <result column="confirm_date" property="confirmDate"/>
        <result column="rzh_type" property="rzhType"/>
        <result column="rzh_yesorno" property="rzhYesorno"/>
        <result column="rzh_back_msg" property="rzhBackMsg"/>
        <result column="dqskssq" property="dqskssq"/>
        <result column="gxjzr" property="gxjzr"/>
        <result column="gxfwq" property="gxfwq"/>
        <result column="gxfwz" property="gxfwz"/>
        <result column="detail_yesorno" property="detailYesorno"/>
        <result column="auth_status" property="authStatus"/>
        <result column="send_date" property="sendDate"/>
        <result column="rzlx" property="rzlx"/>
        <result column="confirm_user" property="confirmUser"/>
        <result column="dept_id" property="deptId"/>
        <result column="dept_name" property="deptName"/>
        <result column="glzt" property="glzt"/>
        <result column="xxly" property="xxly"/>
        <result column="cxrz_status" property="cxrzStatus"/>
        <result column="cxrz_date" property="cxrzDate"/>
        <result column="cxrz_current_period" property="cxrzCurrentPeriod"/>
        <result column="bdk_status" property="bdkStatus"/>
        <result column="cxbdk_status" property="cxbdkStatus"/>
        <result column="cxbdk_date" property="cxbdkDate"/>
        <result column="bdk_current_period" property="bdkCurrentPeriod"/>
        <result column="entry_discrepancy" property="entryDiscrepancy"/>
        <result column="customs_scan_id" property="customsScanId"/>
        <result column="export_mark" property="exportMark"/>
        <result column="entry_date" property="entryDate"/>
        <result column="entry_user" property="entryUser"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, gf_name, gf_tax_no, customs_code, payer_one_taxno, payer_one_name, payer_two_taxno,
    payer_two_name, fill_in_date, tax_amount, yx_tax_amount, import_port_code, income_office,
    applicant_code, bill_code, mode_type, budget_code, treasury_code, contract_code,
    means_transport, payment_period, delivery_code, data_sources, create_date, update_date,
    data_type, collect_upload_status, audit_status, apply_check, fail_reason, check_status,
    qs_status, qs_date, qs_type, qs_user, rzh_date, rzh_belong_date, confirm_date, rzh_type,
    rzh_yesorno, rzh_back_msg, dqskssq, gxjzr, gxfwq, gxfwz, detail_yesorno, auth_status,
    send_date, rzlx, confirm_user, dept_id, dept_name, glzt, xxly, cxrz_status, cxrz_date,
    cxrz_current_period, bdk_status, cxbdk_status, cxbdk_date, bdk_current_period, entry_discrepancy,
    customs_scan_id, export_mark, entry_date, entry_user
    </sql>
    <select databaseId="oracle" id="queryCollect"
            parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO">
        SELECT
        count(1) "number",
        SUM(t.tax_amount) as "taxSum",
        TO_CHAR(t.create_date, 'yyyy-MM-dd') "collectDate",
        gf_tax_no as "gfTaxNo"
        FROM
        t_dx_customs_record t
        where data_type='17'
        <if test="queryParams.normalFlag!=null and queryParams.normalFlag!=''">
            and data_sources = '0'
        </if>
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNoList" index="index" item="item" open="("
                     separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDateBegin!=null and queryParams.createDateBegin!=''">
            and t.create_date &gt;= to_date(#{queryParams.createDateBegin}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= to_date(substr(#{queryParams.createDateEnd} ,1 , 10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.ycpbz!=null and queryParams.ycpbz!=''">
            and glzt != '0' and(entry_discrepancy = '0' or (
            (
            apply_check = '0'
            AND audit_status = '2'
            )
            OR (
            apply_check = '1'
            AND check_status = '1'
            )
            )
            )
        </if>
        GROUP BY
        TO_CHAR(t.create_date, 'yyyy-MM-dd'),
        gf_tax_no
        order by TO_CHAR(t.create_date, 'yyyy-MM-dd') desc
    </select>
    <select id="queryCollect" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO"
            databaseId="mysql">
        SELECT
        count(1) number,
        SUM(t.tax_amount) as taxSum,
        DATE_FORMAT(t.create_date, '%Y-%m-%d') collectDate,
        gf_name as gfName,
        gf_tax_no as gfTaxNo
        FROM
        t_dx_customs_record t
        where 1=1
        <if test="queryParams.normalFlag!=null and queryParams.normalFlag!=''">
            and data_sources = '0'
        </if>
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDateBegin!=null and queryParams.createDateBegin!=''">
            and t.create_date &gt;= #{queryParams.createDateBegin}
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= CONCAT(substring(#{queryParams.createDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.ycpbz!=null and queryParams.ycpbz!=''">
            and glzt != '0' and(entry_discrepancy = '0' or (
            (
            apply_check = '0'
            AND audit_status = '2'
            )
            OR (
            apply_check = '1'
            AND check_status = '1'
            )
            )
            )
        </if>
        GROUP BY
        collectDate,
        gf_tax_no
        order by collectDate desc
    </select>


    <select databaseId="oracle" id="sumTaxAmount"
            parameterType="java.util.Map" resultType="java.util.Map">
        SELECT
        count(1) as "number",
        sum(t.tax_amount) as "taxAmountSum"
        FROM
        t_dx_customs_record t
        where data_type='17'
        <if test="queryParams.normalFlag!=null and queryParams.normalFlag!=''">
            and data_sources = '0'
        </if>
        <if test="queryParams.insertFlag!=null and queryParams.insertFlag!=''">
            and data_sources != '0'
        </if>
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNoList" index="index" item="item" open="("
                     separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDateBegin!=null and queryParams.createDateBegin!=''">
            and t.create_date &gt;= to_date(#{queryParams.createDateBegin}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= to_date(substr(#{queryParams.createDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= to_date(#{queryParams.fillInDateBegin}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.collectUploadStatus!=null and queryParams.collectUploadStatus!=''">
            and t.collect_upload_status = #{queryParams.collectUploadStatus}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.dataSources!=null and queryParams.dataSources!=''">
            and t.data_sources = #{queryParams.dataSources}
        </if>
        <if test="queryParams.ycpbz!=null and queryParams.ycpbz!=''">
            and glzt != '0' and(entry_discrepancy = '0' or (
            (
            apply_check = '0'
            AND audit_status = '2'
            )
            OR (
            apply_check = '1'
            AND check_status = '1'
            )
            )
            )
        </if>
    </select>
    <select id="sumTaxAmount" parameterType="java.util.Map" resultType="java.util.Map" databaseId="mysql">
        SELECT
        count(1) as number,
        sum(t.tax_amount) as taxAmountSum
        FROM
        t_dx_customs_record t
        where 1=1
        <if test="queryParams.insertFlag!=null and queryParams.insertFlag!=''">
            and data_sources !='0'
        </if>
        <if test="queryParams.normalFlag!=null and queryParams.normalFlag!=''">
            and data_sources = '0'
        </if>
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.createDateBegin!=null and queryParams.createDateBegin!=''">
            and t.create_date &gt;= #{queryParams.createDateBegin}
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= CONCAT(substring(#{queryParams.createDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= CONCAT(substring(#{queryParams.fillInDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.collectUploadStatus!=null and queryParams.collectUploadStatus!=''">
            and t.collect_upload_status = #{queryParams.collectUploadStatus}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
        <if test="queryParams.dataSources!=null and queryParams.dataSources!=''">
            and t.data_sources = #{queryParams.dataSources}
        </if>
        <if test="queryParams.maunalSign!=null and queryParams.maunalSign!=''">
            and qs_status = '0' and data_sources in ('0','1')
        </if>
        <if test="queryParams.ycpbz!=null and queryParams.ycpbz!=''">
            AND glzt != '0' and(entry_discrepancy = '0' or (
            (
            apply_check = '0'
            AND audit_status = '2'
            )
            OR (
            apply_check = '1'
            AND check_status = '1'
            )
            )
            )
        </if>
    </select>

    <select id="queryRzcxSum" parameterType="java.util.Map" resultType="java.util.Map">
        SELECT
        sum(p.tax_amount) as taxAmountSum,
        count(p.id) as number
        FROM
        t_dx_customs_record p
        where
        p.export_mark = '0'
        and p.auth_status != '0'
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNo" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

        <if test="queryParams.gfsh!=null and queryParams.gfsh!=''">
            and p.gf_tax_no = #{queryParams.gfsh}
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </if>

        <if test="queryParams.rzhBelongDate!=null and queryParams.rzhBelongDate!=''">
            and p.rzh_belong_date = #{queryParams.rzhBelongDate}
        </if>

        <if test="queryParams.authStatus!=null and queryParams.authStatus!=''">
            and p.auth_status = #{queryParams.authStatus}
        </if>

        <if test="queryParams.confirmUser!=null and queryParams.confirmUser!=''">
            and p.confirm_user = #{queryParams.confirmUser}
        </if>

        <if test="queryParams.rzlx!=null and queryParams.rzlx!=''">
            and p.bdk_status = #{queryParams.rzlx}
        </if>

        <if test="queryParams.rzhYesorno!=null and queryParams.rzhYesorno!=''">
            and p.rzh_yesorno = #{queryParams.rzhYesorno}
        </if>

        <if test="queryParams.rzhDateStart!=null and queryParams.rzhDateStart!=''">
            and p.rzh_date &gt;= #{queryParams.rzhDateStart}
        </if>

        <if test="queryParams.rzhDateEnd!=null and queryParams.rzhDateEnd!=''">
            and p.rzh_date &lt;= #{queryParams.rzhDateEnd}
        </if>

        <if test="queryParams.glzt!=null and queryParams.glzt!=''">
            and p.glzt = #{queryParams.glzt}
        </if>

        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and p.fill_in_date &gt;= #{queryParams.fillInDateStart}
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;= #{queryParams.fillInDateEnd}
        </if>

        <if test="queryParams.taxAmount!=null and queryParams.taxAmount!=''">
            and p.tax_amount = #{queryParams.taxAmount}
        </if>

        <if test="queryParams.taxAmountMin!=null and queryParams.taxAmountMin!=''">
            and p.tax_amount &gt;= #{queryParams.taxAmountMin}
        </if>

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

        <if test="queryParams.qsStatus!=null and queryParams.qsStatus!=''">
            and p.qs_status = #{queryParams.qsStatus}
        </if>

        <if test="queryParams.qsType!=null and queryParams.qsType!=''">
            and p.qs_type = #{queryParams.qsType}
        </if>

        <if test="queryParams.qsName!=null and queryParams.qsName!=''">
            and p.qs_user = #{queryParams.qsName}
        </if>

        <if test="queryParams.qsDateStart!=null and queryParams.qsDateStart!=''">
            and p.qs_date &gt;= #{queryParams.qsDateStart}
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= #{queryParams.qsDateEnd}
        </if>
    </select>

    <select id="queryRzcxByPage" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsRzcxVO"
            databaseId="mysql">
        SELECT
        p.id as id,
        p.customs_code as customsCode,
        date_format(p.fill_in_date,'%Y-%m-%d') as fillInDate,
        p.gf_name as gfName,
        p.gf_tax_no as gfTaxNo,
        p.tax_amount as taxAmount,
        p.yx_tax_amount as yxTaxAmount,
        p.data_sources as dataSources,
        p.qs_status as qsStatus,
        date_format(p.qs_date,'%Y-%m-%d') as qsDate,
        p.qs_type as qsType,
        p.qs_user as qsUser,
        p.apply_check as applyCheck,
        p.audit_status as auditStatus,
        p.glzt as glzt,
        date_format(p.rzh_date,'%Y-%m-%d') as rzhDate,
        p.rzh_yesorno as rzhYesorno,
        p.auth_status as authStatus,
        p.confirm_user as confirmUser,
        p.rzh_belong_date as rzhBelongDate,
        p.cxrz_status as cxrzStatus,
        p.bdk_status as bdkStatus,
        p.dept_name as businessName
        FROM
        t_dx_customs_record p
        where
        p.export_mark = '0'
        and p.auth_status != '0'
        and p.bdk_status in ('1','2')
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNo" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

        <if test="queryParams.gfsh!=null and queryParams.gfsh!=''">
            and p.gf_tax_no = #{queryParams.gfsh}
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </if>

        <if test="queryParams.rzhBelongDate!=null and queryParams.rzhBelongDate!=''">
            and p.rzh_belong_date = #{queryParams.rzhBelongDate}
        </if>

        <if test="queryParams.authStatus!=null and queryParams.authStatus!=''">
            and p.auth_status = #{queryParams.authStatus}
        </if>

        <if test="queryParams.confirmUser!=null and queryParams.confirmUser!=''">
            and p.confirm_user = #{queryParams.confirmUser}
        </if>

        <if test="queryParams.rzlx!=null and queryParams.rzlx!=''">
            and p.bdk_status = #{queryParams.rzlx}
        </if>

        <if test="queryParams.rzhYesorno!=null and queryParams.rzhYesorno!=''">
            and p.rzh_yesorno = #{queryParams.rzhYesorno}
        </if>

        <if test="queryParams.rzhDateStart!=null and queryParams.rzhDateStart!=''">
            and p.rzh_date &gt;= #{queryParams.rzhDateStart}
        </if>

        <if test="queryParams.rzhDateEnd!=null and queryParams.rzhDateEnd!=''">
            and p.rzh_date &lt;= #{queryParams.rzhDateEnd}
        </if>

        <if test="queryParams.glzt!=null and queryParams.glzt!=''">
            and p.glzt = #{queryParams.glzt}
        </if>

        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and p.fill_in_date &gt;= #{queryParams.fillInDateStart}
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;= #{queryParams.fillInDateEnd}
        </if>

        <if test="queryParams.taxAmount!=null and queryParams.taxAmount!=''">
            and p.tax_amount = #{queryParams.taxAmount}
        </if>

        <if test="queryParams.taxAmountMin!=null and queryParams.taxAmountMin!=''">
            and p.tax_amount &gt;= #{queryParams.taxAmountMin}+0
        </if>

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

        <if test="queryParams.qsStatus!=null and queryParams.qsStatus!=''">
            and p.qs_status = #{queryParams.qsStatus}
        </if>

        <if test="queryParams.qsType!=null and queryParams.qsType!=''">
            and p.qs_type = #{queryParams.qsType}
        </if>

        <if test="queryParams.qsName!=null and queryParams.qsName!=''">
            and p.qs_user = #{queryParams.qsName}
        </if>

        <if test="queryParams.qsDateStart!=null and queryParams.qsDateStart!=''">
            and p.qs_date &gt;= #{queryParams.qsDateStart}
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= #{queryParams.qsDateEnd}
        </if>
        <if test="queryParams.businessCode != '99' and queryParams.businessCode != null and queryParams.businessCode != '' and queryParams.businessCode != 'null' ">
            and p.dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode==''">
            and (p.dept_id is null or p.dept_id='' or p.dept_id='99')
        </if>
        <if test='queryParams.businessCode == "99" and queryParams.business!=null and queryParams.business.size()>0'>
            and (p.dept_id in
            <foreach collection="queryParams.business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
        order by p.rzh_date desc,p.confirm_date desc
    </select>

    <select id="queryRzcxByPage" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsRzcxVO"
            databaseId="oracle">
        SELECT
        p.id as id,
        p.customs_code as customsCode,
        to_char(p.fill_in_date,'yyyy-mm-dd') as fillInDate,
        p.gf_name as gfName,
        p.gf_tax_no as gfTaxNo,
        p.tax_amount as taxAmount,
        p.yx_tax_amount as yxTaxAmount,
        p.data_sources as dataSources,
        p.qs_status as qsStatus,
        to_char(p.qs_date,'yyyy-mm-dd') as qsDate,
        p.qs_type as qsType,
        p.qs_user as qsUser,
        p.apply_check as applyCheck,
        p.audit_status as auditStatus,
        p.glzt as glzt,
        to_char(p.rzh_date,'yyyy-mm-dd') as rzhDate,
        p.rzh_yesorno as rzhYesorno,
        p.auth_status as authStatus,
        p.confirm_user as confirmUser,
        p.rzh_belong_date as rzhBelongDate,
        p.cxrz_status as cxrzStatus,
        p.bdk_status as bdkStatus,
        p.dept_name as businessName
        FROM
        t_dx_customs_record p
        where
        p.export_mark = '0'
        and p.auth_status != '0'
        and p.bdk_status in ('1','2')
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNo" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

        <if test="queryParams.gfsh!=null and queryParams.gfsh!=''">
            and p.gf_tax_no = #{queryParams.gfsh}
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </if>

        <if test="queryParams.rzhBelongDate!=null and queryParams.rzhBelongDate!=''">
            and p.rzh_belong_date = #{queryParams.rzhBelongDate}
        </if>

        <if test="queryParams.authStatus!=null and queryParams.authStatus!=''">
            and p.auth_status = #{queryParams.authStatus}
        </if>

        <if test="queryParams.confirmUser!=null and queryParams.confirmUser!=''">
            and p.confirm_user = #{queryParams.confirmUser}
        </if>

        <if test="queryParams.rzlx!=null and queryParams.rzlx!=''">
            and p.bdk_status = #{queryParams.rzlx}
        </if>

        <if test="queryParams.rzhYesorno!=null and queryParams.rzhYesorno!=''">
            and p.rzh_yesorno = #{queryParams.rzhYesorno}
        </if>

        <if test="queryParams.rzhDateStart!=null and queryParams.rzhDateStart!=''">
            and to_char(p.rzh_date,'yyyy-mm-dd') &gt;= #{queryParams.rzhDateStart}
        </if>

        <if test="queryParams.rzhDateEnd!=null and queryParams.rzhDateEnd!=''">
            and to_char(p.rzh_date,'yyyy-mm-dd') &lt;= #{queryParams.rzhDateEnd}
        </if>

        <if test="queryParams.glzt!=null and queryParams.glzt!=''">
            and p.glzt = #{queryParams.glzt}
        </if>

        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and to_char(p.fill_in_date,'yyyy-mm-dd') &gt;= #{queryParams.fillInDateStart}
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and to_char(p.fill_in_date,'yyyy-mm-dd') &lt;= #{queryParams.fillInDateEnd}
        </if>

        <if test="queryParams.taxAmount!=null and queryParams.taxAmount!=''">
            and p.tax_amount = #{queryParams.taxAmount}
        </if>

        <if test="queryParams.taxAmountMin!=null and queryParams.taxAmountMin!=''">
            and p.tax_amount &gt;= #{queryParams.taxAmountMin}+0
        </if>

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

        <if test="queryParams.qsStatus!=null and queryParams.qsStatus!=''">
            and p.qs_status = #{queryParams.qsStatus}
        </if>

        <if test="queryParams.qsType!=null and queryParams.qsType!=''">
            and p.qs_type = #{queryParams.qsType}
        </if>

        <if test="queryParams.qsName!=null and queryParams.qsName!=''">
            and p.qs_user = #{queryParams.qsName}
        </if>

        <if test="queryParams.qsDateStart!=null and queryParams.qsDateStart!=''">
            and to_char(p.qs_date,'yyyy-mm-dd') &gt;= #{queryParams.qsDateStart}
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and to_char(p.qs_date,'yyyy-mm-dd') &lt;= #{queryParams.qsDateEnd}
        </if>
        <if test="queryParams.businessCode != '99' and queryParams.businessCode != null and queryParams.businessCode != '' and queryParams.businessCode != 'null' ">
            and p.dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode==''">
            and (p.dept_id is null or p.dept_id='' or p.dept_id='99')
        </if>
        <if test='queryParams.businessCode == "99" and queryParams.business!=null and queryParams.business.size()>0'>
            and (p.dept_id in
            <foreach collection="queryParams.business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
        order by p.rzh_date desc,p.confirm_date desc
    </select>

    <select id="queryInsertCustoms" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO"
            databaseId="mysql">
        SELECT
        t.customs_code as customsCode,
        date_format(t.fill_in_date,'%Y-%m-%d') as fillInDate,
        date_format(t.entry_date,'%Y-%m-%d') as entryDate,
        t.tax_amount as taxAmount,
        t.collect_upload_status as collectUploadStatus,
        t.audit_status as auditStatus,
        t.apply_check as applyCheck,
        t.check_status as checkStatus,
        t.data_sources as dataSources,
        t.gf_tax_no as gfTaxNo,
        t.gf_name as gfName
        FROM
        t_dx_customs_record t
        where data_sources != '0'
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.createDateBegin!=null and queryParams.createDateBegin!=''">
            and t.create_date &gt;= #{queryParams.createDateBegin}
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= CONCAT(substring(#{queryParams.createDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= CONCAT(substring(#{queryParams.fillInDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.collectUploadStatus!=null and queryParams.collectUploadStatus!=''">
            and t.collect_upload_status = #{queryParams.collectUploadStatus}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
        <if test="queryParams.dataSources!=null and queryParams.dataSources!=''">
            and t.data_sources = #{queryParams.dataSources}
        </if>
        order by t.create_date desc
    </select>
    <select databaseId="oracle" id="queryInsertCustoms"
            parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO">
        SELECT
        t.customs_code as "customsCode",
        to_char(t.fill_in_date,'yyyy-MM-dd') as "fillInDate",
        to_char(t.entry_date,'yyyy-MM-dd') as "entryDate",
        t.tax_amount as "taxAmount",
        t.collect_upload_status as "collectUploadStatus",
        t.audit_status as "auditStatus",
        t.apply_check as "applyCheck",
        t.check_status as "checkStatus",
        t.data_sources as "dataSources",
        t.gf_tax_no as "gfTaxNo",
        t.gf_name as "gfName"

        FROM
        t_dx_customs_record t
        where t.data_sources != '0'
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNoList" index="index" item="item" open="("
                     separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.createDateBegin!=null and queryParams.createDateBegin!=''">
            and t.create_date &gt;= to_date(#{queryParams.createDateBegin}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= to_date(substr(#{queryParams.createDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= to_date(#{queryParams.fillInDateBegin}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.collectUploadStatus!=null and queryParams.collectUploadStatus!=''">
            and t.collect_upload_status = #{queryParams.collectUploadStatus}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
        <if test="queryParams.dataSources!=null and queryParams.dataSources!=''">
            and t.data_sources = #{queryParams.dataSources}
        </if>
        order by t.create_date desc
    </select>
    <select id="queryManualSign" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO"
            databaseId="oracle">
        SELECT
        t.id,
        t.customs_code as customsCode,
        to_char(t.fill_in_date,'yyyy-MM-dd') AS fillInDate,
        t.gf_tax_no as gfTaxNo,
        t.gf_name as gfName,
        t.tax_amount as taxAmount,
        t.data_sources as dataSources,
        t.glzt,
        t.audit_status as auditStatus,
        t.apply_check as applyCheck,
        t.check_status as checkStatus,
        t.entry_discrepancy as entryDiscrepancy
        FROM
        t_dx_customs_record t
        where t.qs_status = '0'
        and t.export_mark = '0'
        and (t.data_sources = '0' or (t.data_sources != '0' and t.collect_upload_status = '2'))
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!='' and queryParams.gfTaxNo!='99'">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and to_char(t.fill_in_date,'yyyy-MM-dd hh24:mi:ss') &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and to_char(t.fill_in_date,'yyyy-MM-dd hh24:mi:ss') &lt;= CONCAT(substr(#{queryParams.fillInDateEnd},1,10),'
            23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
    </select>
    <select id="queryManualSign" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO"
            databaseId="mysql">
        SELECT
        t.id,
        t.customs_code as customsCode,
        date_format(t.fill_in_date,'%Y-%m-%d') AS fillInDate,
        t.gf_tax_no as gfTaxNo,
        t.gf_name as gfName,
        t.tax_amount as taxAmount,
        t.data_sources as dataSources,
        t.glzt,
        t.audit_status as auditStatus,
        t.apply_check as applyCheck,
        t.check_status as checkStatus,
        t.entry_discrepancy as entryDiscrepancy
        FROM
        t_dx_customs_record t
        where t.qs_status = '0'
        and t.export_mark = '0'
        and (t.data_sources = '0' or (t.data_sources != '0' and t.collect_upload_status = '2'))
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!='' and queryParams.gfTaxNo!='99'">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= CONCAT(substring(#{queryParams.fillInDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
    </select>


    <select id="sumSignTaxAmount" parameterType="java.util.Map" resultType="java.util.Map">
        SELECT
        sum(t.tax_amount) AS taxAmountSum
        FROM
        t_dx_customs t
        where t.user_account = #{queryParams.userAccount}
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!='' and queryParams.gfTaxNo!='99'">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>

        <if test="queryParams.qsDateBegin!=null and queryParams.qsDateBegin!=''">
            and t.qs_date &gt;= #{queryParams.qsDateBegin}
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and t.qs_date &lt;= CONCAT(substring(#{queryParams.qsDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= CONCAT(substring(#{queryParams.fillInDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
        <if test="queryParams.qsStatus!=null and queryParams.qsStatus!=''">
            and t.qs_status = #{queryParams.qsStatus}
        </if>
        <if test="queryParams.notes!=null and queryParams.notes!=''">
            and t.notes like concat('%',concat(#{queryParams.notes},'%'))
        </if>
        <if test="queryParams.qsType!=null and queryParams.qsType!=''">
            and t.qs_type = #{queryParams.qsType}
        </if>
        <if test="queryParams.businessCode!=null and queryParams.businessCode!='' and queryParams.businessCode!='99'">
            and t.dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode == ''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test="queryParams.company != null and queryParams.company !=''">
            and t.company = #{queryParams.company}
        </if>
    </select>

    <select id="querySign" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO"
            databaseId="oracle">
        SELECT
        t.id,
        t.notes,
        to_char(t.qs_date,'yyyy-MM-dd') AS qsDate,
        t.qs_status AS qsStatus,
        t.user_name AS userName,
        t.qs_type AS qsType,
        t.xxly,
        t.glzt,
        t.customs_code AS customsCode,
        to_char(t.fill_in_date,'yyyy-MM-dd') AS fillInDate,
        t.gf_tax_no AS gfTaxNo,
        t.gf_name AS gfName,
        t.tax_amount AS taxAmount,
        t.audit_status AS auditStatus,
        t.apply_check AS applyCheck,
        t.check_status AS checkStatus,
        t.remark,
        t.scan_id AS scanId,
        t.data_sources as dataSources,
        t.dept_name as deptName
        FROM
        t_dx_customs t
        where t.user_account = #{queryParams.userAccount}
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!='' and queryParams.gfTaxNo!='99'">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>

        <if test="queryParams.qsDateBegin!=null and queryParams.qsDateBegin!=''">
            and to_char(t.qs_date,'yyyy-MM-dd hh24:mi:ss') &gt;= #{queryParams.qsDateBegin}
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and to_char(t.qs_date,'yyyy-MM-dd hh24:mi:ss') &lt;= CONCAT(substr(#{queryParams.qsDateEnd},1,10),'
            23:59:59')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and to_char(t.fill_in_date,'yyyy-MM-dd hh24:mi:ss') &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and to_char(t.fill_in_date,'yyyy-MM-dd hh24:mi:ss') &lt;= CONCAT(substr(#{queryParams.fillInDateEnd},1,10),'
            23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
        <if test="queryParams.qsStatus!=null and queryParams.qsStatus!=''">
            and t.qs_status = #{queryParams.qsStatus}
        </if>
        <if test="queryParams.notes!=null and queryParams.notes!=''">
            and t.notes like concat('%',concat(#{queryParams.notes},'%'))
        </if>
        <if test="queryParams.qsType!=null and queryParams.qsType!=''">
            and t.qs_type = #{queryParams.qsType}
        </if>
        <if test="queryParams.businessCode!=null and queryParams.businessCode!='' and queryParams.businessCode!='99'">
            and t.dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode == ''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        order by t.invoice_serial_no desc
    </select>
    <select id="querySign" parameterType="java.util.Map" resultType="com.dxhy.core.model.CustomsCollectVO"
            databaseId="mysql">
        SELECT
        t.id,
        t.notes,
        date_format(t.qs_date,'%Y-%m-%d') AS qsDate,
        t.qs_status AS qsStatus,
        t.user_name AS userName,
        t.qs_type AS qsType,
        t.xxly,
        t.glzt,
        t.customs_code AS customsCode,
        date_format(t.fill_in_date,'%Y-%m-%d') AS fillInDate,
        t.gf_tax_no AS gfTaxNo,
        t.gf_name AS gfName,
        t.tax_amount AS taxAmount,
        t.audit_status AS auditStatus,
        t.apply_check AS applyCheck,
        t.check_status AS checkStatus,
        t.remark,
        t.scan_id AS scanId,
        t.data_sources as dataSources,
        t.dept_name as deptName
        FROM
        t_dx_customs t
        where t.user_account = #{queryParams.userAccount}
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and t.gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!='' and queryParams.gfTaxNo!='99'">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>

        <if test="queryParams.qsDateBegin!=null and queryParams.qsDateBegin!=''">
            and t.qs_date &gt;= #{queryParams.qsDateBegin}
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and t.qs_date &lt;= CONCAT(substring(#{queryParams.qsDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.fillInDateBegin!=null and queryParams.fillInDateBegin!=''">
            and t.fill_in_date &gt;= #{queryParams.fillInDateBegin}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and t.fill_in_date &lt;= CONCAT(substring(#{queryParams.fillInDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and t.customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.auditStatus!=null and queryParams.auditStatus!=''">
            and t.audit_status = #{queryParams.auditStatus}
        </if>
        <if test="queryParams.applyCheck!=null and queryParams.applyCheck!=''">
            and t.apply_check = #{queryParams.applyCheck}
        </if>
        <if test="queryParams.checkStatus!=null and queryParams.checkStatus!=''">
            and t.check_status = #{queryParams.checkStatus}
        </if>
        <if test="queryParams.qsStatus!=null and queryParams.qsStatus!=''">
            and t.qs_status = #{queryParams.qsStatus}
        </if>
        <if test="queryParams.notes!=null and queryParams.notes!=''">
            and t.notes like concat('%',concat(#{queryParams.notes},'%'))
        </if>
        <if test="queryParams.qsType!=null and queryParams.qsType!=''">
            and t.qs_type = #{queryParams.qsType}
        </if>
        <if test="queryParams.businessCode!=null and queryParams.businessCode!='' and queryParams.businessCode!='99'">
            and t.dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode == ''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        order by t.invoice_serial_no desc
    </select>
    <select id="queryCustomsRefundConfirmList" parameterType="com.dxhy.core.model.BaseCustomsVO"
            resultType="com.dxhy.core.model.CustomsRecordVO" databaseId="mysql">
        select
        id as id,
        customs_code as customsCode,
        date_format(fill_in_date,'%Y-%m-%d') as fillInDate,
        gf_name as gfName,
        glzt, dqskssq, rzlx,
        gf_tax_no as gfTaxNo,
        tax_amount as taxAmount,
        yx_tax_amount as yxTaxAmount,
        data_sources as dataSources,
        qs_status as qsStatus,
        date_format(qs_date,'%Y-%m-%d') as qsDate,
        qs_type as qsType,
        qs_user as qsUser,
        apply_check as applyCheck,
        audit_status as auditStatus,
        date_format(rzh_date,'%Y-%m-%d') as rzhDate,
        rzh_yesorno as rzhYesorno,
        auth_status as authStatus,
        confirm_user as confirmUser,
        rzh_belong_date as rzhBelongDate,
        dept_name as deptName
        from t_dx_customs_record
        where
        <include refid="queryCustomsRefundConfirm_sql"/>
    </select>
    <select id="queryCustomsRefundConfirmSum" parameterType="java.util.Map" resultType="java.util.Map"
            databaseId="mysql">
        select
        count(1) as hjsl,
        sum(tax_amount) as hjse
        from t_dx_customs_record
        where
        <include refid="queryCustomsRefundConfirm_sql"/>
    </select>
    <sql id="queryCustomsRefundConfirm_sql">
        auth_status != '0' and (rzlx = '2' or  rzlx = '3')
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and fill_in_date &gt;= #{queryParams.fillInDateStart}
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and fill_in_date &lt;= CONCAT(substring(#{queryParams.fillInDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.belongDateStart!=null and queryParams.belongDateStart!=''">
            and fill_in_date &gt;= #{queryParams.belongDateStart}
        </if>
        <if test="queryParams.belongDateEnd!=null and queryParams.belongDateEnd!=''">
            and fill_in_date &lt;= CONCAT(substring(#{queryParams.belongDateEnd},1,10),' 23:59:59')
        </if>
<!--        <if test="queryParams.taxAmountStart!=null and queryParams.taxAmountStart!=''">-->
<!--            and cast(tax_amount as DECIMAL) &gt;= #{queryParams.taxAmountStart}-->
<!--        </if>-->
<!--        <if test="queryParams.taxAmountEnd!=null and queryParams.taxAmountEnd!=''">-->
<!--            and cast(tax_amount as DECIMAL) &lt;= #{queryParams.taxAmountEnd}-->
<!--        </if>-->
        <if test="queryParams.taxAmountStart!=null and queryParams.taxAmountStart!=''">
            and tax_amount &gt;= #{queryParams.taxAmountStart}+0
        </if>

        <if test="queryParams.taxAmountEnd!=null and queryParams.taxAmountEnd!=''">
            and tax_amount &lt;= #{queryParams.taxAmountEnd}+0
        </if>
        <if test="queryParams.signStatus!=null and queryParams.signStatus!=''">
            and qs_status = #{queryParams.signStatus}
        </if>
        <if test="queryParams.signDateStart!=null and queryParams.signDateStart!=''">
            and qs_date &gt;= #{queryParams.signDateStart}
        </if>
        <if test="queryParams.signDateEnd!=null and queryParams.signDateEnd!=''">
            and qs_date &lt;= CONCAT(substring(#{queryParams.signDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.manageStatus!=null and queryParams.manageStatus!=''">
            and glzt = #{queryParams.manageStatus}
        </if>
        <if test="queryParams.confirmStatus!=null and queryParams.confirmStatus!=''">
            and rzh_yesorno = #{queryParams.confirmStatus}
        </if>
        <if test="queryParams.authStatus!=null and queryParams.authStatus!=''">
            and auth_status = #{queryParams.authStatus}
        </if>
        <if test="queryParams.confirmUser!=null and queryParams.confirmUser!=''">
            and confirm_user = #{queryParams.confirmUser}
        </if>
        <if test="queryParams.rzhDateStart!=null and queryParams.rzhDateStart!=''">
            and rzh_date &gt;= #{queryParams.rzhDateStart}
        </if>
        <if test="queryParams.rzhDateEnd!=null and queryParams.rzhDateEnd!=''">
            and rzh_date &lt;= CONCAT(substring(#{queryParams.rzhDateEnd},1,10),' 23:59:59')
        </if>
        <if test="queryParams.belongDate!=null and queryParams.belongDate!=''">
            and rzh_belong_date = #{queryParams.belongDate}
        </if>
        <if test="queryParams.businessCode != '99' and queryParams.businessCode != null and queryParams.businessCode != '' and queryParams.businessCode != 'null' ">
            and dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode==''">
            and (dept_id is null or dept_id='' or dept_id='99')
        </if>
        <if test='queryParams.businessCode == "99" and queryParams.business != null and queryParams.business.size()>0'>
            and (dept_id in
            <foreach collection="queryParams.business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (dept_id is null or dept_id='' or dept_id='99'))
        </if>
        <if test="queryParams.company !='' and queryParams.company!=null">
            and company = #{queryParams.company}
        </if>
    </sql>
    <select id="queryCustomsRefundConfirmList" parameterType="com.dxhy.core.model.BaseCustomsVO"
            resultType="com.dxhy.core.model.CustomsRecordVO" databaseId="oracle">
        select
        id as id,
        customs_code as customsCode,
        to_char(fill_in_date,'yyyy-mm-dd') as fillInDate,
        gf_name as gfName,
        glzt, dqskssq, rzlx,
        gf_tax_no as gfTaxNo,
        tax_amount as taxAmount,
        yx_tax_amount as yxTaxAmount,
        data_sources as dataSources,
        qs_status as qsStatus,
        to_char(qs_date,'yyyy-mm-dd') as qsDate,
        qs_type as qsType,
        qs_user as qsUser,
        apply_check as applyCheck,
        audit_status as auditStatus,
        to_char(rzh_date,'yyyy-mm-dd') as rzhDate,
        rzh_yesorno as rzhYesorno,
        auth_status as authStatus,
        confirm_user as confirmUser,
        rzh_belong_date as rzhBelongDate,
        dept_name as deptName
        from t_dx_customs_record
        where
        <include refid="queryCustomsRefundConfirm_oracle"/>
    </select>
    <select id="queryCustomsRefundConfirmSum" parameterType="java.util.Map" resultType="java.util.Map"
            databaseId="oracle">
        select
        count(1) as hjsl,
        sum(tax_amount) as hjse
        from t_dx_customs_record
        where
        <include refid="queryCustomsRefundConfirm_oracle"/>
    </select>
    <sql id="queryCustomsRefundConfirm_oracle">
        auth_status != '0' and (rzlx = '2' or rzlx = '3')
        <if test="queryParams.gfTaxNoList!=null  and queryParams.gfTaxNoList.size>0">
            and gf_tax_no in
            <foreach item="item" index="index" collection="queryParams.gfTaxNoList" open="(" separator="," close=")">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and customs_code = #{queryParams.customsCode}
        </if>
        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and fill_in_date &gt;= to_date(#{queryParams.fillInDateStart},'yyyy-mm-dd')
        </if>
        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and fill_in_date &lt;= to_date(CONCAT(substr(#{queryParams.fillInDateEnd},1,10),' 23:59:59'),'yyyy-mm-dd
            hh24:mi:ss')
        </if>
        <if test="queryParams.belongDateStart!=null and queryParams.belongDateStart!=''">
            and fill_in_date &gt;= to_date(#{queryParams.belongDateStart},'yyyy-mm-dd')
        </if>
        <if test="queryParams.belongDateEnd!=null and queryParams.belongDateEnd!=''">
            and fill_in_date &lt;= to_date(CONCAT(substr(#{queryParams.belongDateEnd},1,10),' 23:59:59'),'yyyy-mm-dd
            hh24:mi:ss')
        </if>
<!--        <if test="queryParams.taxAmountStart!=null and queryParams.taxAmountStart!=''">-->
<!--            and cast(tax_amount as DECIMAL) &gt;= #{queryParams.taxAmountStart}-->
<!--        </if>-->
<!--        <if test="queryParams.taxAmountEnd!=null and queryParams.taxAmountEnd!=''">-->
<!--            and cast(tax_amount as DECIMAL) &lt;= #{queryParams.taxAmountEnd}-->
<!--        </if>-->
        <if test="queryParams.taxAmountStart!=null and queryParams.taxAmountStart!=''">
            and tax_amount &gt;= #{queryParams.taxAmountStart}+0
        </if>

        <if test="queryParams.taxAmountEnd!=null and queryParams.taxAmountEnd!=''">
            and tax_amount &lt;= #{queryParams.taxAmountEnd}+0
        </if>
        <if test="queryParams.signStatus!=null and queryParams.signStatus!=''">
            and qs_status = #{queryParams.signStatus}
        </if>
        <if test="queryParams.signDateStart!=null and queryParams.signDateStart!=''">
            and qs_date &gt;= to_date(#{queryParams.signDateStart},'yyyy-mm-dd')
        </if>
        <if test="queryParams.signDateEnd!=null and queryParams.signDateEnd!=''">
            and qs_date &lt;= to_date(CONCAT(substr(#{queryParams.signDateEnd},1,10),' 23:59:59'),'yyyy-mm-dd
            hh24:mi:ss')
        </if>
        <if test="queryParams.manageStatus!=null and queryParams.manageStatus!=''">
            and glzt = #{queryParams.manageStatus}
        </if>
        <if test="queryParams.confirmStatus!=null and queryParams.confirmStatus!=''">
            and rzh_yesorno = #{queryParams.confirmStatus}
        </if>
        <if test="queryParams.authStatus!=null and queryParams.authStatus!=''">
            and auth_status = #{queryParams.authStatus}
        </if>
        <if test="queryParams.confirmUser!=null and queryParams.confirmUser!=''">
            and confirm_user = #{queryParams.confirmUser}
        </if>
        <if test="queryParams.rzhDateStart!=null and queryParams.rzhDateStart!=''">
            and rzh_date &gt;= to_date(#{queryParams.rzhDateStart},'yyyy-mm-dd')
        </if>
        <if test="queryParams.rzhDateEnd!=null and queryParams.rzhDateEnd!=''">
            and rzh_date &lt;= to_date(CONCAT(substr(#{queryParams.rzhDateEnd},1,10),' 23:59:59'),'yyyy-mm-dd
            hh24:mi:ss')
        </if>
        <if test="queryParams.belongDate!=null and queryParams.belongDate!=''">
            and rzh_belong_date = #{queryParams.belongDate}
        </if>
        <if test="queryParams.businessCode != '99' and queryParams.businessCode != null and queryParams.businessCode != '' and queryParams.businessCode != 'null' ">
            and dept_id = #{queryParams.businessCode}
        </if>
        <if test="queryParams.businessCode==''">
            and (dept_id is null or dept_id='' or dept_id='99')
        </if>
        <if test='queryParams.businessCode == "99" and queryParams.business != null and queryParams.business.size()>0'>
            and (dept_id in
            <foreach collection="queryParams.business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (dept_id is null or dept_id='' or dept_id='99'))
        </if>
        <if test="queryParams.company !='' and queryParams.company!=null">
            and company = #{queryParams.company}
        </if>
    </sql>
</mapper>
