<?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.customs.dao.CustomsRecordDao">

    <!-- 通用查询映射结果 -->
    <delete databaseId="mysql" id="deleteCustomsScan">
        delete
        from t_dx_customs
        where scan_id = #{scanId}
    </delete>

    <delete databaseId="mysql" id="deleteCustomsImg">
        delete
        from t_dx_customs_img
        where scan_id = #{scanId}
    </delete>

    <delete databaseId="oracle" id="deleteCustomsScan">
        delete
        from t_dx_customs
        where scan_id = #{scanId}
    </delete>


    <delete databaseId="oracle" id="deleteCustomsImg">
        delete
        from t_dx_customs_img
        where scan_id = #{scanId}
    </delete>

    <resultMap id="BaseResultMap" type="com.dxhy.customs.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>

    <select databaseId="mysql" id="queryCollect"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        count(1) number,
        SUM(t.tax_amount) as taxSum,
        DATE_FORMAT(t.create_date, '%Y-%m-%d') 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;= #{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.exceptionFlag!=null and queryParams.exceptionFlag!=''">
            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="mysql" id="queryCollectDetail"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.customs_code as customsCode,
        DATE_FORMAT(t.fill_in_date,'%Y-%m-%d') as fillInDate,
        t.tax_amount as taxAmount
        FROM
        t_dx_customs_record t
        WHERE
        t.data_sources = '0'
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDate!=null and queryParams.createDate!=''">
            and DATE_FORMAT(t.create_date,'%Y-%m-%d') = #{queryParams.createDate}
        </if>
        order by t.fill_in_date desc
    </select>

    <select databaseId="mysql" id="sumTaxAmount"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        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.entryFlag!=null and queryParams.entryFlag!=''">
            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;= #{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;= #{queryParams.fillInDateEnd}
        </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.exceptionFlag!=null and queryParams.exceptionFlag!=''">
            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 databaseId="mysql" id="querySgByPage"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        p.id as id,
        p.customs_code as customsCode,
        DATE_FORMAT(p.fill_in_date ,'%Y-%m-%d') 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') 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,
        p.entry_discrepancy as entryDiscrepancy,
        p.rzh_yesorno as rzhYesorno,
        p.data_type as dataType,
        p.export_mark as exportMark,
        p.auth_status as authStatus,
        p.check_status as checkStatus,
        p.dept_name as businessName,
        p.inaccount_status as inAccountStatus,
        p.bzdh as bzdh,
        p.image_id as imageNumber,
        p.account_period as accountPeriod,
        p.posting_time as postingTime,
        p.sn_voucher_number as snVoucherNumber,
        p.bzr as bzr,
        p.comp_code as compCode
        FROM
        t_dx_customs_record p
        where
        p.rzh_yesorno = '0'
        and p.gf_tax_no = #{queryParams.gfsh}
        and (p.comp_code = #{queryParams.companyCode} or p.comp_code = '' or p.comp_code is null)
        and p.auth_status in('0','5','6')
        and p.data_type = '17'
        and p.export_mark = '0'
        and p.data_sources = '0'

        <if test="queryParams.bzdh != null and queryParams.bzdh != '' and queryParams.bzdh != 'null'">
            and p.bzdh = #{queryParams.bzdh}
        </if>
        <if test="queryParams.inAccountStatus != null and queryParams.inAccountStatus != '' and queryParams.inAccountStatus != 'null' and queryParams.inAccountStatus != '99' ">
            and p.inaccount_status = #{queryParams.inAccountStatus}
        </if>

        <if test="queryParams.snVoucherNumber != null and queryParams.snVoucherNumber != '' and queryParams.snVoucherNumber != 'null' and queryParams.snVoucherNumber != '99'">
            and p.sn_voucher_number = #{queryParams.snVoucherNumber}
        </if>
        <if test="queryParams.postingTimeStart != null and queryParams.postingTimeStart != '' and queryParams.postingTimeStart != 'null' and queryParams.postingTimeStart != '99' and queryParams.postingTimeEnd != null and queryParams.postingTimeEnd != '' and queryParams.postingTimeEnd != 'null' and queryParams.postingTimeEnd != '99'">
            and p.posting_time between #{queryParams.postingTimeStart} and #{queryParams.postingTimeEnd}
        </if>
        <if test="queryParams.imageNumber != null and queryParams.imageNumber != '' and queryParams.imageNumber != 'null' and queryParams.imageNumber != '99'">
            and p.image_id = #{queryParams.imageNumber}
        </if>
        <if test="queryParams.accountPeriod != null and queryParams.accountPeriod != '' and queryParams.accountPeriod != 'null' and queryParams.accountPeriod != '99'">
            and p.account_period = #{queryParams.accountPeriod}
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </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.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.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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
        order by p.entry_date desc

    </select>


    <select databaseId="mysql" id="querySgBySum"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        count(1) as hjsl,
        '' as hjje,
        sum(p.tax_amount) as hjse
        FROM
        t_dx_customs_record p
        where
        p.rzh_yesorno = '0'
        and p.gf_tax_no = #{queryParams.gfsh}
        and (p.comp_code = #{queryParams.companyCode} or p.comp_code = '' or p.comp_code is null)
        and p.auth_status in('0','5','6')
        and p.data_type = '17'
        and p.export_mark = '0'
        and p.data_sources = '0'

        <if test="queryParams.bzdh != null and queryParams.bzdh != '' and queryParams.bzdh != 'null'">
            and p.bzdh = #{queryParams.bzdh}
        </if>
        <if test="queryParams.inAccountStatus != null and queryParams.inAccountStatus != '' and queryParams.inAccountStatus != 'null' and queryParams.inAccountStatus != '99' ">
            and p.inaccount_status = #{queryParams.inAccountStatus}
        </if>

        <if test="queryParams.snVoucherNumber != null and queryParams.snVoucherNumber != '' and queryParams.snVoucherNumber != 'null' and queryParams.snVoucherNumber != '99'">
            and p.sn_voucher_number = #{queryParams.snVoucherNumber}
        </if>
        <if test="queryParams.postingTimeStart != null and queryParams.postingTimeStart != '' and queryParams.postingTimeStart != 'null' and queryParams.postingTimeStart != '99' and queryParams.postingTimeEnd != null and queryParams.postingTimeEnd != '' and queryParams.postingTimeEnd != 'null' and queryParams.postingTimeEnd != '99'">
            and p.posting_time between #{queryParams.postingTimeStart} and #{queryParams.postingTimeEnd}
        </if>
        <if test="queryParams.imageNumber != null and queryParams.imageNumber != '' and queryParams.imageNumber != 'null' and queryParams.imageNumber != '99'">
            and p.image_id = #{queryParams.imageNumber}
        </if>
        <if test="queryParams.accountPeriod != null and queryParams.accountPeriod != '' and queryParams.accountPeriod != 'null' and queryParams.accountPeriod != '99'">
            and p.account_period = #{queryParams.accountPeriod}
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </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.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.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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
    </select>


    <select databaseId="mysql" id="queryBdkByPage"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        p.id as id,
        p.customs_code as customsCode,
        DATE_FORMAT(p.fill_in_date,'%Y-%m-%d') as fillInDate,
        DATE_FORMAT(p.qs_date,'%Y-%m-%d') as qsDate,
        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,
        p.qs_type as qsType,
        p.qs_user as qsUser,
        p.apply_check as applyCheck,
        p.audit_status as auditStatus,
        p.auth_status as authStatus,
        p.cxbdk_status as cxbdkStatus,
        p.check_status as checkStatus,
        p.glzt as glzt,
        p.entry_discrepancy as entryDiscrepancy,
        p.bdk_status as bdkStatus,
        p.dept_name as businessName,
        p.rzh_belong_date as rzhBelongDate,
        p.bdk_yy as bdkYy,
        p.bdk_message as bdkMessage,
        p.inaccount_status as inAccountStatus,
        p.bzdh as bzdh,
        p.image_id as imageNumber,
        p.account_period as accountPeriod,
        p.posting_time as postingTime,
        p.sn_voucher_number as snVoucherNumber,
        p.bzr as bzr,
        p.comp_code as compCode
        FROM
        t_dx_customs_record p
        where
        p.data_type = '17'
        and p.gf_tax_no = #{queryParams.gfsh}
        and (p.comp_code = #{queryParams.companyCode} or p.comp_code = '' or p.comp_code is null)
        and p.export_mark = '0'

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '0'.toString()">
            and (p.auth_status in('0','5','6') or (p.bdk_status = '2' and p.auth_status != '4')) and p.data_sources =
            '0'
        </if>

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '4'.toString()">
            and p.bdk_status = '2' and p.auth_status='4'
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
        order by rzh_date desc

    </select>


    <select databaseId="mysql" id="queryBdkBySum"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        count(1) as hjsl,
        '' as hjje,
        sum(p.tax_amount) as hjse
        FROM
        t_dx_customs_record p
        where
        p.data_type = '17'
        and p.gf_tax_no = #{queryParams.gfsh}
        and (p.comp_code = #{queryParams.companyCode} or p.comp_code = '' or p.comp_code is null)
        and p.export_mark = '0'
        and p.data_sources = '0'

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '0'.toString()">
            and (p.auth_status in('0','5','6') or (p.bdk_status = '2' and p.auth_status != '4'))
        </if>

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '4'.toString()">
            and p.bdk_status = '2' and p.auth_status='4'
        </if>

        <if test="queryParams.customsCode!=null and queryParams.customsCode!=''">
            and p.customs_code = #{queryParams.customsCode}
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
    </select>

    <select databaseId="mysql" id="insertQuery"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.id,
        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,
        t.fail_reason failReason

        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.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;= #{queryParams.createDateEnd}
        </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;= #{queryParams.fillInDateEnd}
        </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="mysql" id="queryExcptionDetail"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.customs_code as customsCode,
        DATE_FORMAT(t.fill_in_date,'%Y-%m-%d') as fillInDate,
        t.tax_amount as taxAmount,
        t.audit_status as auditStatus,
        t.check_status as checkStatus,
        t.glzt,
        DATE_FORMAT(t.status_update_date,'%Y-%m-%d')  as statusUpdateDate
        FROM
        t_dx_customs_record t
        WHERE
        glzt != '0' and(entry_discrepancy = '0' or (
        (
        apply_check = '0'
        AND audit_status = '2'
        )
        OR (
        apply_check = '1'
        AND check_status = '1'
        )
        )
        )
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDate!=null and queryParams.createDate!=''">
            and DATE_FORMAT(t.create_date,'%Y-%m-%d') = #{queryParams.createDate}
        </if>
        order by t.fill_in_date desc
    </select>

    <select databaseId="mysql" id="queryManualSign"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.id,
        t.customs_code as customsCode,
        DATE_FORMAT(t.fill_in_date,'%Y-%m-%d') 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,
        t.sn_voucher_number as snVoucherNumber,
        t.posting_time as postingTime,
        t.image_id as imageNumber,
        t.account_period as accountPeriod,
        t.bzdh as bzdh,
        t.bzr as bzr,
        t.inaccount_status as  inAccountStatus,
        t.comp_code as compCode
        FROM
        t_dx_customs_record t
        where t.qs_status = '0'
        and t.gf_tax_no = #{gfsh}
        and (t.comp_code = #{companyCode} or t.comp_code = '' or t.comp_code is null)
        and t.export_mark = '0'
        and (t.data_sources = '0' or (t.data_sources != '0' and t.collect_upload_status = '2'))
        <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 databaseId="mysql" id="queryRzcxByPage"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        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.rzh_back_msg as rzhBackMsg,
        p.cxrz_status as cxrzStatus,
        p.bdk_status as bdkStatus,
        p.dept_name as businessName,
        p.inaccount_status as inAccountStatus,
        p.bzdh as bzdh,
        p.image_id as imageNumber,
        p.account_period as accountPeriod,
        p.posting_time as postingTime,
        p.sn_voucher_number as snVoucherNumber,
        p.bzr as bzr,
        p.comp_code as compCode
        FROM
        t_dx_customs_record p
        where
        p.export_mark = '0'
        and p.gf_tax_no = #{queryParams.gfsh}
        and (p.comp_code = #{queryParams.companyCode} or p.comp_code = '' or p.comp_code is null)
        and p.auth_status != '0'
        and p.bdk_status in ('1','2')

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

        <if test="queryParams.inAccountStatus != null and queryParams.inAccountStatus != '' and queryParams.inAccountStatus != 'null' and queryParams.inAccountStatus != '99'">
            and p.inaccount_status = #{queryParams.inAccountStatus}
        </if>
<!--        <if test="queryParams.snVoucherNumber != null and queryParams.snVoucherNumber != '' and queryParams.snVoucherNumber != 'null' and queryParams.snVoucherNumber != '99'">-->
<!--            and p.sn_voucher_number = #{queryParams.snVoucherNumber}-->
<!--        </if>-->
        <if test="queryParams.postingTimeStart != null and queryParams.postingTimeStart != '' and queryParams.postingTimeStart != 'null' and queryParams.postingTimeStart != '99' and queryParams.postingTimeEnd != null and queryParams.postingTimeEnd != '' and queryParams.postingTimeEnd != 'null' and queryParams.postingTimeEnd != '99'">
            and p.posting_time between #{queryParams.postingTimeStart} and #{queryParams.postingTimeEnd}
        </if>
        <if test="queryParams.imageNumber != null and queryParams.imageNumber != '' and queryParams.imageNumber != 'null' and queryParams.imageNumber != '99'">
            and p.image_id = #{queryParams.imageNumber}
        </if>
        <if test="queryParams.accountPeriod != null and queryParams.accountPeriod != '' and queryParams.accountPeriod != 'null' and queryParams.accountPeriod != '99'">
            and p.account_period = #{queryParams.accountPeriod}
        </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.confirmUserList != null and queryParams.confirmUserList.size() > 0">
            and p.confirm_user in
            <foreach collection="queryParams.confirmUserList" index="index" item="item"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </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  queryParams.rzhYesorno != 3">
            and p.rzh_yesorno = #{queryParams.rzhYesorno}
        </if>
        <if test="queryParams.rzhYesorno!=null and queryParams.rzhYesorno!='' and  queryParams.rzhYesorno == 3">
            and (p.rzh_yesorno = '1' or p.rzh_yesorno = '2')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{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 databaseId="mysql" id="querySign"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.id,
        t.notes,
        DATE_FORMAT(t.qs_date,'%Y-%m-%d') 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') 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,
        r.sn_voucher_number as snVoucherNumber,
        r.posting_time as postingTime,
        r.image_id as imageNumber,
        r.account_period as accountPeriod,
        r.bzdh as bzdh,
        r.bzr as bzr,
        r.inaccount_status as  inAccountStatus,
        r.comp_code as compCode
        FROM
        t_dx_customs t left join t_dx_customs_record r on t.customs_code = r.customs_code
        where  r.gf_tax_no = #{gfsh}
        and (r.comp_code = #{companyCode} or r.comp_code = '' or r.comp_code is null)
        t.user_account = #{queryParams.userAccount}
        <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 databaseId="mysql" id="selectDkse"
            parameterType="java.util.Map" resultType="com.dxhy.customs.entity.TdxCustomsRecord">
        select sum(t.yx_tax_amount) yxTaxAmount
        from t_dx_customs_record t
        WHERE t.data_type = '17'
          and (t.rzh_yesorno = '1' or t.auth_status in ('2', '3', '4'))
          and t.gf_tax_no = #{gfsh}
          and t.rzh_belong_date = #{skssq}

    </select>


    <select databaseId="mysql" id="queryRzcxBySum"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        count(1) as hjsl,
        '' as hjje,
        sum(p.tax_amount) as hjse
        FROM
        t_dx_customs_record p
        where
        p.export_mark = '0'
        and p.gf_tax_no = #{queryParams.gfsh}
        and (p.comp_code = #{queryParams.companyCode} or p.comp_code = '' or p.comp_code is null)
        and p.auth_status != '0'
        and p.bdk_status in ('1','2')
        <if test="queryParams.bzdh != null and queryParams.bzdh != '' and queryParams.bzdh != 'null'">
            and p.bzdh = #{queryParams.bzdh}
        </if>
<!--        <if test="queryParams.inAccountStatus != null and queryParams.inAccountStatus != '' and queryParams.inAccountStatus != 'null'">-->
<!--            and p.inaccount_status = #{queryParams.inAccountStatus}-->
<!--        </if>-->
<!--        <if test="queryParams.snVoucherNumber != null and queryParams.snVoucherNumber != '' and queryParams.snVoucherNumber != 'null' and queryParams.snVoucherNumber != '99'">-->
<!--            and p.sn_voucher_number = #{queryParams.snVoucherNumber}-->
<!--        </if>-->
        <if test="queryParams.postingTimeStart != null and queryParams.postingTimeStart != '' and queryParams.postingTimeStart != 'null' and queryParams.postingTimeStart != '99' and queryParams.postingTimeEnd != null and queryParams.postingTimeEnd != '' and queryParams.postingTimeEnd != 'null' and queryParams.postingTimeEnd != '99'">
            and p.posting_time between #{queryParams.postingTimeStart} and #{queryParams.postingTimeEnd}
        </if>
        <if test="queryParams.imageNumber != null and queryParams.imageNumber != '' and queryParams.imageNumber != 'null' and queryParams.imageNumber != '99'">
            and p.image_id = #{queryParams.imageNumber}
        </if>
        <if test="queryParams.accountPeriod != null and queryParams.accountPeriod != '' and queryParams.accountPeriod != 'null' and queryParams.accountPeriod != '99'">
            and p.account_period = #{queryParams.accountPeriod}
        </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.confirmUserList != null and queryParams.confirmUserList.size() > 0">
            and p.confirm_user in
            <foreach collection="queryParams.confirmUserList" index="index" item="item"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </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 queryParams.rzhYesorno != 3">
            and p.rzh_yesorno = #{queryParams.rzhYesorno}
        </if>
        <if test="queryParams.rzhYesorno!=null and queryParams.rzhYesorno!='' and queryParams.rzhYesorno == 3">
            and (p.rzh_yesorno = '1' or p.rzh_yesorno = '2')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
    </select>


    <!-- ====================================== ↓↓↓↓↓↓ oracle ↓↓↓↓↓↓  ====================================== -->

    <select databaseId="oracle" id="queryCollect"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        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.exceptionFlag!=null and queryParams.exceptionFlag!=''">
            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 databaseId="oracle" id="queryCollectDetail"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.customs_code as "customsCode",
        TO_CHAR(t.fill_in_date,'yyyy-MM-dd') as "fillInDate",
        t.tax_amount as "taxAmount"
        FROM
        t_dx_customs_record t
        WHERE
        t.data_sources = '0'
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDate!=null and queryParams.createDate!=''">
            and TO_CHAR(t.create_date,'yyyy-MM-dd') = #{queryParams.createDate}
        </if>
        order by t.fill_in_date desc
    </select>

    <select databaseId="oracle" id="sumTaxAmount"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        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.entryFlag!=null and queryParams.entryFlag!=''">
            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;= #{queryParams.createDateBegin}
        </if>
        <if test="queryParams.createDateEnd!=null and queryParams.createDateEnd!=''">
            and t.create_date &lt;= #{queryParams.createDateEnd}
        </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;= #{queryParams.fillInDateEnd}
        </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.exceptionFlag!=null and queryParams.exceptionFlag!=''">
            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 databaseId="oracle" id="querySgByPage"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        p.id as "id",
        p.customs_code as "customsCode",
        to_date(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_date(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",
        p.entry_discrepancy as "entryDiscrepancy",
        p.rzh_yesorno as "rzhYesorno",
        p.data_type as "dataType",
        p.export_mark as "exportMark",
        p.auth_status as "authStatus",
        p.check_status as "checkStatus",
        p.dept_name as "businessName"
        FROM
        t_dx_customs_record p
        where
        p.rzh_yesorno = '0'
        and p.auth_status in('0','5','6')
        and p.data_type = '17'
        and p.export_mark = '0'
        and p.data_sources = '0'
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNo" index="index" item="item" open="("
                     separator=",">
                #{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.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.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and p.fill_in_date &gt;= to_date(#{queryParams.fillInDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;= to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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;= to_date(#{queryParams.qsDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= to_date(substr(#{queryParams.qsDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
        order by p.entry_date desc

    </select>

    <select databaseId="oracle" id="querySgBySum"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        count(1) as "hjsl",
        '' as "hjje",
        sum(p.tax_amount) as "hjse"
        FROM
        t_dx_customs_record p
        where
        p.rzh_yesorno = '0'
        and p.auth_status in('0','5','6')
        and p.data_type = '17'
        and p.export_mark = '0'
        and p.data_sources = '0'
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNo" index="index" item="item" open="("
                     separator=",">
                #{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.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.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and p.fill_in_date &gt;= to_date(#{queryParams.fillInDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;= to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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;= to_date(#{queryParams.qsDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= to_date(substr(#{queryParams.qsDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
    </select>

    <select databaseId="oracle" id="queryBdkByPage"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        p.id as "id",
        p.customs_code as "customsCode",
        to_date(p.fill_in_date, 'yyyy-MM-dd') as "fillInDate",
        to_date(p.qs_date, 'yyyy-MM-dd') as "qsDate",
        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",
        p.qs_type as "qsType",
        p.qs_user as "qsUser",
        p.apply_check as "applyCheck",
        p.audit_status as "auditStatus",
        p.auth_status as "authStatus",
        p.cxbdk_status as "cxbdkStatus",
        p.check_status as "checkStatus",
        p.glzt as "glzt",
        p.entry_discrepancy as "entryDiscrepancy",
        p.bdk_status as "bdkStatus",
        p.dept_name as "businessName",
        p.bdk_yy as "bdkYy",
        p.bdk_message as "bdkMessage"
        FROM
        t_dx_customs_record p
        where
        p.data_type = '17'
        and p.export_mark = '0'
        and p.data_sources = '0'
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNo" index="index" item="item" open="("
                     separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

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

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '0'.toString()">
            and (p.auth_status in('0','5','6') or (p.bdk_status = '2' and p.auth_status != '4'))
        </if>

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '4'.toString()">
            and p.bdk_status = '2' and p.auth_status='4'
        </if>

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

        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and p.fill_in_date &gt;= to_date(#{queryParams.fillInDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;= to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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;= to_date(#{queryParams.qsDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= to_date(substr(#{queryParams.qsDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
        order by rzh_date desc

    </select>

    <select databaseId="oracle" id="queryBdkBySum"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        count(1) as "hjsl",
        '' as "hjje",
        sum(p.tax_amount) as "hjse"
        FROM
        t_dx_customs_record p
        where
        p.data_type = '17'
        and p.export_mark = '0'
        and p.data_sources = '0'
        <if test="queryParams.gfTaxNo!=null  and queryParams.gfTaxNo.size>0">
            and p.gf_tax_no in
            <foreach close=")" collection="queryParams.gfTaxNo" index="index" item="item" open="("
                     separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>

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

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '0'.toString()">
            and (p.auth_status in('0','5','6') or (p.bdk_status = '2' and p.auth_status != '4'))
        </if>

        <if test="queryParams.sfDkStatus!=null and queryParams.sfDkStatus == '4'.toString()">
            and p.bdk_status = '2' and p.auth_status='4'
        </if>

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

        <if test="queryParams.fillInDateStart!=null and queryParams.fillInDateStart!=''">
            and p.fill_in_date &gt;= to_date(#{queryParams.fillInDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;= to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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;= to_date(#{queryParams.qsDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= to_date(substr(#{queryParams.qsDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
    </select>


    <select databaseId="oracle" id="insertQuery"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        to_char(t.id) as "id",
        t.customs_code as "customsCode",
        to_date(t.fill_in_date, 'yyyy-MM-dd') as "fillInDate",
        to_date(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",
        t.fail_reason "failReason"

        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.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;= #{queryParams.createDateEnd}
        </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;= #{queryParams.fillInDateEnd}
        </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 databaseId="oracle" id="queryExcptionDetail"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        t.customs_code as "customsCode",
        TO_CHAR(t.fill_in_date,'yyyy-MM-dd') as "fillInDate",
        t.tax_amount as "taxAmount",
        t.audit_status as "auditStatus",
        t.check_status as "checkStatus",
        t.glzt as "glzt",
        TO_CHAR(t.status_update_date,'yyyy-MM-dd') as "statusUpdateDate"
        FROM
        t_dx_customs_record t
        WHERE
        glzt != '0' and(entry_discrepancy = '0' or (
        (
        apply_check = '0'
        AND audit_status = '2'
        )
        OR (
        apply_check = '1'
        AND check_status = '1'
        )
        )
        )
        <if test="queryParams.gfTaxNo!=null and queryParams.gfTaxNo!=''">
            and t.gf_tax_no = #{queryParams.gfTaxNo}
        </if>
        <if test="queryParams.createDate!=null and queryParams.createDate!=''">
            and TO_CHAR(t.create_date,'yyyy-MM-dd') = #{queryParams.createDate}
        </if>
        order by t.fill_in_date desc
    </select>


    <select databaseId="oracle" id="queryManualSign"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        to_char(t.id) as "id",
        t.customs_code as "customsCode",
        to_date(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 as "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 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.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.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 databaseId="oracle" id="queryRzcxByPage"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        to_char(p.id) as "id",
        p.customs_code as "customsCode",
        to_date(p.fill_in_date, 'yyyy-MM-dd') as "fillInDate",
        to_date(p.qs_date, 'yyyy-MM-dd') as "qsDate",
        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",
        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_date(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.rzh_back_msg as rzhBackMsg,
        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 close=")" collection="queryParams.gfTaxNo" index="index" item="item" open="("
                     separator=",">
                #{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.confirmUserList != null and queryParams.confirmUserList.size() > 0">
            and p.confirm_user in
            <foreach collection="queryParams.confirmUserList" index="index" item="item"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </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;= to_date(#{queryParams.rzhDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>

        <if test="queryParams.rzhDateEnd!=null and queryParams.rzhDateEnd!=''">
            and p.rzh_date &lt;= to_date(substr(#{queryParams.rzhDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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;= to_date(#{queryParams.fillInDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>

        <if test="queryParams.fillInDateEnd!=null and queryParams.fillInDateEnd!=''">
            and p.fill_in_date &lt;=to_date(substr(#{queryParams.fillInDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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;= to_date(#{queryParams.qsDateStart}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and p.qs_date &lt;= to_date(substr(#{queryParams.qsDateEnd},1,10) || ' 23:59:59',
            'yyyy-MM-dd hh24:mi:ss')
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{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 databaseId="oracle" id="querySign"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordDTO" resultType="java.util.Map">
        SELECT
        to_char(t.id) as "id",
        t.notes as "notes",
        to_date(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 as "xxly",
        t.glzt as "glzt",
        t.customs_code AS "customsCode",
        to_date(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 as "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 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.qsDateBegin!=null and queryParams.qsDateBegin!=''">
            and t.qs_date &gt;= to_date(#{queryParams.qsDateBegin}, 'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="queryParams.qsDateEnd!=null and queryParams.qsDateEnd!=''">
            and t.qs_date &lt;= to_date(substr(#{queryParams.qsDateEnd},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.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 ('%' || (#{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 databaseId="oracle" id="selectDkse"
            parameterType="java.util.Map" resultType="com.dxhy.customs.entity.TdxCustomsRecord">
        select sum(t.yx_tax_amount) "yxTaxAmount"
        from t_dx_customs_record t
        WHERE t.data_type = '17'
          and (t.rzh_yesorno = '1' or t.auth_status in ('2', '3', '4'))
          and t.gf_tax_no = #{gfsh}
          and t.rzh_belong_date = #{skssq}

    </select>

    <select databaseId="oracle" id="queryRzcxBySum"
            parameterType="com.dxhy.customs.model.TdxCustomsRecordModelDTO" resultType="java.util.Map">
        SELECT
        count(1) as "hjsl",
        '' as "hjje",
        sum(p.tax_amount) as "hjse"
        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 close=")" collection="queryParams.gfTaxNo" index="index" item="item" open="("
                     separator=",">
                #{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.confirmUserList != null and queryParams.confirmUserList.size() > 0">
            and p.confirm_user in
            <foreach collection="queryParams.confirmUserList" index="index" item="item"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </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 close="" collection="queryParams.business" index="index" item="item" open="("
                     separator=",">
                #{item.businessCode}
            </foreach>
            ) or (p.dept_id is null or p.dept_id='' or p.dept_id='99'))
        </if>
    </select>

    <!--    <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>-->

    <update databaseId="mysql" id="updateRecordSign">
        update t_dx_customs_record
        set qs_status = '0',
            qs_date   = null,
            qs_type   = null,
            qs_user   = null
        where customs_code = #{customsCode}
    </update>


    <update databaseId="oracle" id="updateRecordSign">
        update t_dx_customs_record
        set qs_status = '0',
            qs_date   = null,
            qs_type   = null,
            qs_user   = null
        where customs_code = #{customsCode}
    </update>


</mapper>
