<?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.portrait.business.dao.MixedSignatureDao">
    <resultMap id="BaseResultMap" type="com.dxhy.portrait.business.entity.TDxScanImg">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="scan_record_id" jdbcType="VARCHAR" property="scanRecordId"/>
        <result column="file_type" jdbcType="VARCHAR" property="fileType"/>
        <result column="item_no" jdbcType="INTEGER" property="itemNo"/>
        <result column="scan_id" jdbcType="VARCHAR" property="scanId"/>
        <result column="doc_format" jdbcType="VARCHAR" property="docFormat"/>
        <result column="bills_number" jdbcType="VARCHAR" property="billsNumber"/>
        <result column="serial_number" jdbcType="VARCHAR" property="serialNumber"/>
        <result column="image_local_path" jdbcType="VARCHAR" property="imageLocalPath"/>
        <result column="image_path" jdbcType="VARCHAR" property="imagePath"/>
        <result column="image_name" jdbcType="VARCHAR" property="imageName"/>
        <result column="original_name" jdbcType="VARCHAR" property="originalName"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
        <result column="create_data" jdbcType="TIMESTAMP" property="createData"/>
    </resultMap>

    <select id="getScaninfoByEwm" resultType="com.dxhy.portrait.business.entity.TDxInvoiceReimburse">
        select *
        from t_dx_invoice_reimburse
        where ewm = #{ewm}
          and file_type = '0'
    </select>

    <select id="getRecordByUuid" resultType="com.dxhy.portrait.business.entity.TDxRecordInvoice">
        select *
        from t_dx_record_invoice
        where uuid = #{uuid}
    </select>
    <select id="getInvoiceByUuid" resultType="com.dxhy.portrait.business.entity.TDxInvoice">
        select *
        from t_dx_invoice
        where uuid = #{uuid}
    </select>

    <update id="updateReimbursement" parameterType="map" databaseId="mysql">
        UPDATE t_dx_invoice_reimburse
        <set>
            <choose>
                <when test="param.invoiceType!= null and param.invoiceType!= '' ">
                    invoice_type=#{param.invoiceType},
                </when>
                <otherwise>
                    invoice_type= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceCode!= null and param.invoiceCode!= ''">
                    invoice_code=#{param.invoiceCode},
                </when>
                <otherwise>
                    invoice_code= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceNo!= null and param.invoiceNo!= ''">
                    invoice_no=#{param.invoiceNo},
                </when>
                <otherwise>
                    invoice_no= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceDate!= null and param.invoiceDate!= ''">
                    invoice_date=#{param.invoiceDate},
                </when>
                <otherwise>
                    invoice_date = NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.ticketNumber!= null and param.ticketNumber!= ''">
                    ticket_number=#{param.ticketNumber},
                </when>
                <otherwise>
                    ticket_number= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.passenger!= null and param.passenger!= ''">passenger=#{param.passenger},
                </when>
                <otherwise>
                    passenger= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceAmount!= null and param.invoiceAmount!= ''">
                    invoice_amount=#{param.invoiceAmount},
                </when>
                <otherwise>
                    invoice_amount= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.taxAmount!= null and param.taxAmount!= ''">
                    tax_amount=#{param.taxAmount},
                </when>
                <otherwise>
                    tax_amount= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.totalAmount!= null and param.totalAmount!= ''">
                    total_amount=#{param.totalAmount},
                </when>
                <otherwise>
                    total_amount= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceStatus!= null and param.invoiceStatus!= ''">
                    invoice_status=#{param.invoiceStatus},
                </when>
                <otherwise>
                    invoice_status= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.dqskssq!= null and param.dqskssq!= ''">dqskssq=#{param.dqskssq},</when>
                <otherwise>
                    dqskssq= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.sourceSystem!= null and param.sourceSystem!= ''">
                    source_system=#{param.sourceSystem},
                </when>
                <otherwise>
                    source_system= '1' ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.departureCity!= null and param.departureCity!= ''">
                    departure_city=#{param.departureCity},
                </when>
                <otherwise>
                    departure_city= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.reachingCity!= null and param.reachingCity!= ''">
                    reaching_city=#{param.reachingCity},
                </when>
                <otherwise>
                    reaching_city= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.trainNumber!= null and param.trainNumber!= ''">
                    train_number=#{param.trainNumber},
                </when>
                <otherwise>
                    train_number= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.ticketDepartureTime!= null and param.ticketDepartureTime!= ''">
                    ticket_departure_time=#{param.ticketDepartureTime},
                </when>
                <otherwise>
                    ticket_departure_time= NULL,
                </otherwise>
            </choose>
            <choose>
                <when test="param.ticketArrivalTime!= null and param.ticketArrivalTime!= ''">
                    ticket_arrival_time=#{param.ticketArrivalTime},
                </when>
                <otherwise>
                    ticket_arrival_time=NULL,
                </otherwise>
            </choose>
            <choose>
                <when test="param.passengerSfzh!= null and param.passengerSfzh!= ''">
                    passenger_s_f_z_h=#{param.passengerSfzh},
                </when>
                <otherwise>
                    passenger_s_f_z_h= NULL ,
                </otherwise>
            </choose>
            <if test="param.xfName!= null and param.xfName!= ''">xf_name=#{param.xfName},</if>
            <if test="param.xfAddressAndPhone!= null and param.xfAddressAndPhone!= ''">
                xf_address_and_phone=#{param.xfAddressAndPhone},
            </if>
            <if test="param.xfBankAndNo!= null and param.xfBankAndNo!= ''">
                xf_bank_and_no=#{param.xfBankAndNo},
            </if>
            <if test="param.gfTaxNo!= null and param.gfTaxNo!= ''">gf_tax_no=#{param.gfTaxNo},</if>
            <if test="param.gfName!= null and param.gfName!= ''">gf_name=#{param.gfName},</if>
            <if test="param.gfAddressAndPhone!= null and param.gfAddressAndPhone!= ''">
                gf_address_and_phone=#{param.gfAddressAndPhone},
            </if>
            <if test="param.gfBankAndNo!= null and param.gfBankAndNo!= ''">
                gf_bank_and_no=#{param.gfBankAndNo},
            </if>
            <if test="param.xfTaxNo!= null and param.xfTaxNo!= ''">xf_tax_no=#{param.xfTaxNo},</if>
            <if test="param.taxRate!= null and param.taxRate!= ''">tax_rate=#{param.taxRate},</if>
            <choose>
                <when test="param.fare!= null and param.fare!= ''">fare=#{param.fare},</when>
                <otherwise>
                    fare= NULL ,
                </otherwise>
            </choose>
            <if test="param.isDeduction!= null and param.isDeduction!= ''">
                is_deduction=#{param.isDeduction},
            </if>
            <if test="param.uuid!= null and param.uuid!= ''">uuid=#{param.uuid},</if>
            <if test="param.isDomestic!= null and param.isDomestic!= ''">
                is_domestic=#{param.isDomestic},
            </if>
            <if test="param.rzhYesorno!= null and param.rzhYesorno!= ''">
                rzh_yesorno=#{param.rzhYesorno},
            </if>
            <if test="param.selectId!= null and param.selectId!= ''">select_id=#{param.selectId},</if>
            <if test="param.qsDate!= null and param.qsDate!= ''">qs_date=#{param.qsDate},</if>
            <if test="param.qsStatus!= null and param.qsStatus!= ''">qs_status=#{param.qsStatus},</if>
            <if test="param.fileType!= null and param.fileType!= ''">file_type=#{param.fileType},</if>
            <if test="param.checkCode!= null and param.checkCode!= ''">check_code=#{param.checkCode},</if>
            <if test="param.qzStatus!= null and param.qzStatus!= ''">qz_status=#{param.qzStatus},</if>
            <if test="param.qsType!= null and param.qsType!= ''">qs_type=#{param.qsType},</if>
            <if test="param.qsName!= null and param.qsName!= ''">qs_name=#{param.qsName},</if>
            <if test="param.fuelSurcharge!= null and param.fuelSurcharge!= ''">
                fuel_surcharge=#{param.fuelSurcharge},
            </if>
            <if test="param.caacDevelopmentFund!= null and param.caacDevelopmentFund!= ''">
                caac_development_fund=#{param.caacDevelopmentFund},
            </if>
            <if test="param.notes!= null and param.notes!= ''">notes=#{param.notes},</if>
            <if test="param.ewm!= null and param.ewm!= ''">ewm=#{param.ewm},</if>
            update_date=now()
        </set>
        WHERE id=#{param.id}
    </update>
    <update id="updateReimbursement" parameterType="map" databaseId="oracle">
        UPDATE t_dx_invoice_reimburse
        <set>
            <choose>
                <when test="param.invoiceType!= null and param.invoiceType!= '' ">
                    invoice_type=#{param.invoiceType},
                </when>
                <otherwise>
                    invoice_type= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceCode!= null and param.invoiceCode!= ''">
                    invoice_code=#{param.invoiceCode},
                </when>
                <otherwise>
                    invoice_code= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceNo!= null and param.invoiceNo!= ''">
                    invoice_no=#{param.invoiceNo},
                </when>
                <otherwise>
                    invoice_no= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceDate!= null and param.invoiceDate!= ''">
                    invoice_date=#{param.invoiceDate},
                </when>
                <otherwise>
                    invoice_date = NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.ticketNumber!= null and param.ticketNumber!= ''">
                    ticket_number=#{param.ticketNumber},
                </when>
                <otherwise>
                    ticket_number= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.passenger!= null and param.passenger!= ''">passenger=#{param.passenger},
                </when>
                <otherwise>
                    passenger= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceAmount!= null and param.invoiceAmount!= ''">
                    invoice_amount=#{param.invoiceAmount},
                </when>
                <otherwise>
                    invoice_amount= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.taxAmount!= null and param.taxAmount!= ''">
                    tax_amount=#{param.taxAmount},
                </when>
                <otherwise>
                    tax_amount= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.totalAmount!= null and param.totalAmount!= ''">
                    total_amount=#{param.totalAmount},
                </when>
                <otherwise>
                    total_amount= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.invoiceStatus!= null and param.invoiceStatus!= ''">
                    invoice_status=#{param.invoiceStatus},
                </when>
                <otherwise>
                    invoice_status= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.dqskssq!= null and param.dqskssq!= ''">dqskssq=#{param.dqskssq},</when>
                <otherwise>
                    dqskssq= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.sourceSystem!= null and param.sourceSystem!= ''">
                    source_system=#{param.sourceSystem},
                </when>
                <otherwise>
                    source_system= '1' ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.departureCity!= null and param.departureCity!= ''">
                    departure_city=#{param.departureCity},
                </when>
                <otherwise>
                    departure_city= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.reachingCity!= null and param.reachingCity!= ''">
                    reaching_city=#{param.reachingCity},
                </when>
                <otherwise>
                    reaching_city= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.trainNumber!= null and param.trainNumber!= ''">
                    train_number=#{param.trainNumber},
                </when>
                <otherwise>
                    train_number= NULL ,
                </otherwise>
            </choose>
            <choose>
                <when test="param.ticketDepartureTime!= null and param.ticketDepartureTime!= ''">
                    ticket_departure_time=#{param.ticketDepartureTime},
                </when>
                <otherwise>
                    ticket_departure_time= NULL,
                </otherwise>
            </choose>
            <choose>
                <when test="param.ticketArrivalTime!= null and param.ticketArrivalTime!= ''">
                    ticket_arrival_time=#{param.ticketArrivalTime},
                </when>
                <otherwise>
                    ticket_arrival_time=NULL,
                </otherwise>
            </choose>
            <choose>
                <when test="param.passengerSfzh!= null and param.passengerSfzh!= ''">
                    passenger_s_f_z_h=#{param.passengerSfzh},
                </when>
                <otherwise>
                    passenger_s_f_z_h= NULL ,
                </otherwise>
            </choose>
            <if test="param.xfName!= null and param.xfName!= ''">xf_name=#{param.xfName},</if>
            <if test="param.xfAddressAndPhone!= null and param.xfAddressAndPhone!= ''">
                xf_address_and_phone=#{param.xfAddressAndPhone},
            </if>
            <if test="param.xfBankAndNo!= null and param.xfBankAndNo!= ''">
                xf_bank_and_no=#{param.xfBankAndNo},
            </if>
            <if test="param.gfTaxNo!= null and param.gfTaxNo!= ''">gf_tax_no=#{param.gfTaxNo},</if>
            <if test="param.gfName!= null and param.gfName!= ''">gf_name=#{param.gfName},</if>
            <if test="param.gfAddressAndPhone!= null and param.gfAddressAndPhone!= ''">
                gf_address_and_phone=#{param.gfAddressAndPhone},
            </if>
            <if test="param.gfBankAndNo!= null and param.gfBankAndNo!= ''">
                gf_bank_and_no=#{param.gfBankAndNo},
            </if>
            <if test="param.xfTaxNo!= null and param.xfTaxNo!= ''">xf_tax_no=#{param.xfTaxNo},</if>
            <if test="param.taxRate!= null and param.taxRate!= ''">tax_rate=#{param.taxRate},</if>
            <choose>
                <when test="param.fare!= null and param.fare!= ''">fare=#{param.fare},</when>
                <otherwise>
                    fare= NULL ,
                </otherwise>
            </choose>
            <if test="param.isDeduction!= null and param.isDeduction!= ''">
                is_deduction=#{param.isDeduction},
            </if>
            <if test="param.uuid!= null and param.uuid!= ''">uuid=#{param.uuid},</if>
            <if test="param.isDomestic!= null and param.isDomestic!= ''">
                is_domestic=#{param.isDomestic},
            </if>
            <if test="param.rzhYesorno!= null and param.rzhYesorno!= ''">
                rzh_yesorno=#{param.rzhYesorno},
            </if>
            <if test="param.selectId!= null and param.selectId!= ''">select_id=#{param.selectId},</if>
            <if test="param.qsDate!= null and param.qsDate!= ''">qs_date=#{param.qsDate},</if>
            <if test="param.qsStatus!= null and param.qsStatus!= ''">qs_status=#{param.qsStatus},</if>
            <if test="param.fileType!= null and param.fileType!= ''">file_type=#{param.fileType},</if>
            <if test="param.checkCode!= null and param.checkCode!= ''">check_code=#{param.checkCode},</if>
            <if test="param.qzStatus!= null and param.qzStatus!= ''">qz_status=#{param.qzStatus},</if>
            <if test="param.qsType!= null and param.qsType!= ''">qs_type=#{param.qsType},</if>
            <if test="param.qsName!= null and param.qsName!= ''">qs_name=#{param.qsName},</if>
            <if test="param.fuelSurcharge!= null and param.fuelSurcharge!= ''">
                fuel_surcharge=#{param.fuelSurcharge},
            </if>
            <if test="param.caacDevelopmentFund!= null and param.caacDevelopmentFund!= ''">
                caac_development_fund=#{param.caacDevelopmentFund},
            </if>
            <if test="param.notes!= null and param.notes!= ''">notes=#{param.notes},</if>
            <if test="param.ewm!= null and param.ewm!= ''">ewm=#{param.ewm},</if>
            update_date=sysdate
        </set>
        WHERE id=#{param.id}
    </update>
    <update id="updateReimbursementByFj" parameterType="map" databaseId="mysql">
        UPDATE t_dx_invoice_reimburse
        <set>

            <if test="param.fileType!= null and param.fileType!= ''">file_type=#{param.fileType},</if>
            <if test="param.ewm!= null and param.ewm!= ''">ewm=#{param.ewm},</if>
            update_date=now(),
            invoice_type =null,
            invoice_code =null,
            invoice_no =null,
            invoice_date=null,
            ticket_number =null,
            passenger=null,
            invoice_amount =null,
            tax_amount =null,
            total_amount =null,
            invoice_status =null,
            departure_city =null,
            reaching_city =null,
            train_number =null,
            ticket_departure_time =null,
            ticket_arrival_time =null,
            passenger_s_f_z_h =null,
            uuid=#{param.uuid},
            gf_tax_no =null,
            gf_address_and_phone =null,
            gf_bank_and_no =null,
            xf_address_and_phone =null,
            xf_bank_and_no =null,
            gf_name =null,
            xf_tax_no =null,
            xf_name=null,
            tax_rate =null,
            check_code =null,
            notes =null
        </set>
        WHERE id=#{param.id}
    </update>
    <update id="updateReimbursementByFj" parameterType="map" databaseId="oracle">
        UPDATE t_dx_invoice_reimburse
        <set>

            <if test="param.fileType!= null and param.fileType!= ''">file_type=#{param.fileType},</if>
            <if test="param.ewm!= null and param.ewm!= ''">ewm=#{param.ewm},</if>
            update_date=sysdate,
            invoice_type =null,
            invoice_code =null,
            invoice_no =null,
            invoice_date=null,
            ticket_number =null,
            passenger=null,
            invoice_amount =null,
            tax_amount =null,
            total_amount =null,
            invoice_status =null,
            departure_city =null,
            reaching_city =null,
            train_number =null,
            ticket_departure_time =null,
            ticket_arrival_time =null,
            passenger_s_f_z_h =null,
            uuid=scan_id,
            gf_tax_no =null,
            gf_address_and_phone =null,
            gf_bank_and_no =null,
            xf_address_and_phone =null,
            xf_bank_and_no =null,
            gf_name =null,
            xf_tax_no =null,
            xf_name=null,
            tax_rate =null,
            check_code =null,
            notes =null
        </set>
        WHERE id=#{param.id}
    </update>
    <update id="confirm" databaseId="mysql">
        UPDATE t_dx_invoice_reimburse
        SET qz_status='1',
            qs_status='1',
            qs_date=now()
        WHERE id = #{id}
    </update>
    <update id="confirm" databaseId="oracle">
        UPDATE t_dx_invoice_reimburse
        SET qz_status='1',
            qs_status='1',
            qs_date=sysdate
        WHERE id = #{id}
    </update>

    <delete id="deletemixed" parameterType="String">
        DELETE
        FROM t_dx_invoice_reimburse
        WHERE id = #{id}
    </delete>
    <delete id="deleteInvoice">
        delete
        from t_dx_invoice
        where id = #{id}
    </delete>
    <select id="getImgByScanId" resultType="com.dxhy.portrait.business.entity.TDxInvoiceImg">
        select *
        from t_dx_invoice_img
        where scan_id = #{scanId}
    </select>

    <select id="selectQsfpList" parameterType="java.util.Map"
            resultType="com.dxhy.portrait.business.entity.SmyqsWqsfpVO" databaseId="mysql">
        select * from (
        select
        t.id,
        t.invoice_type invoiceType,
        t.invoice_code invoiceCode,
        t.invoice_no invoiceNo,
        date_format(t.invoice_date,'%Y-%m-%d') invoiceDate,
        r.ticket_number ticketNumber,
        r.passenger,
        t.invoice_amount invoiceAmount,
        t.tax_amount taxAmount,
        t.total_amount totalAmount,
        t.invoice_status invoiceStatus,
        r.dqskssq,
        r.source_system sourceSystem,
        r.departure_city departureCity,
        r.reaching_city reachingCity,
        r.related_business_documents relatedBusinessDocumes,
        r.business_document_maker businessDocumentMaker,
        r.business_document_number businessDocumentNumber,
        r.reimbursement_time reimbursementTime,
        r.reimbursement_status reimbursementStatus,
        r.train_number trainNumber,
        r.ticket_departure_time ticketDepartureTime,
        r.ticket_arrival_time ticketArrivalTime,
        r.passenger_s_f_z_h passengerSfzh,
        t.uuid,
        t.gf_tax_no gfTaxNo,
        r.gf_address_and_phone gfAddressAndPhone,
        r.gf_bank_and_no gfBankAndNo,
        r.xf_address_and_phone xfAddressAndPhone,
        r.xf_bank_and_no xfBankAndNo,
        t.gf_name gfName,
        t.xf_tax_no xfTaxNo,
        t.xf_name xfName,
        r.tax_rate taxRate,
        date_format(t.create_date,'%Y-%m-%d') createDate,
        r.rzh_yesorno rzhYesorno,
        r.tag,
        r.is_deduction isDeduction,
        r.is_domestic isDomestic,
        r.select_id selectId,
        t.qs_date qsDate,
        t.qs_type qsType,
        t.qs_name qsName,
        t.qs_status qsStatus,
        t.scan_id scanId,
        t.invoice_remark remark,
        '1' fileType,
        t.check_code checkCode,
        r.qz_status qzStatus,
        r.ewm,
        r.orientation,
        r.region,
        r.fuel_surcharge fuelSurcharge,
        r.caac_development_fund caacDevelopmentFund,
        t.update_date updateDate,
        r.fare,
        t.notes,
        t.dept_name businessName,
        '0'isHunsao
        from t_dx_invoice t left join t_dx_invoice_reimburse r on t.uuid = r.uuid
        where t.user_name=#{param.userName} and ((t.qs_status='0' and r.id is null) or (t.qs_status='1' and
        (r.qs_status!='1' or r.qs_status is null)))
        <if
                test="param.invoiceType != '99' and param.invoiceType != null and param.invoiceType != '' and param.invoiceType != 'null'">
            and t.invoice_type = #{param.invoiceType}
        </if>
        <if
                test="param.fileType != '99' and param.fileType != null and param.fileType != '' and param.fileType != 'null'">
            and r.file_type = #{param.fileType}
        </if>
        <if
                test="param.businessCode != '99' and param.businessCode != null and param.businessCode != '' and param.businessCode != 'null'">
            and t.dept_id = #{param.businessCode}
        </if>
        <if test="param.businessCode == ''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if
                test="param.createDateBegin != null and param.createDateBegin != '' and param.createDateBegin != 'null' ">
            <![CDATA[ AND t.create_date >= #{param.createDateBegin} ]]>
        </if>
        <if
                test="param.createDateEnd != null and param.createDateEnd != '' and param.createDateEnd != 'null' ">
            <![CDATA[ AND t.create_date <= #{param.createDateEnd} ]]>
        </if>
        <if test="param.xfName != null and param.xfName != ''">
            and t.xf_name LIKE concat(#{param.xfName},'%')
        </if>
        <if test="param.ewm != null and param.ewm != ''">
            and r.ewm LIKE concat(#{param.ewm},'%')
        </if>
        <if test="param.qzStatus != null and param.qzStatus != '' and param.qzStatus != '99'">
            and r.qz_status = #{param.qzStatus}
        </if>
        <if test="param.gfsh != null and param.gfsh != '' and param.gfsh != '99'">
            and t.gf_tax_no = #{param.gfsh}
        </if>
        <if test="param.qsStatus != null and param.qsStatus != '' and param.qsStatus != '99'">
            and t.qs_status = #{param.qsStatus}
        </if>

        union all
        select
        r.id,
        r.invoice_type invoiceType,
        r.invoice_code invoiceCode,
        r.invoice_no invoiceNo,
        date_format(r.invoice_date,'%Y-%m-%d') invoiceDate,
        r.ticket_number ticketNumber,
        r.passenger,
        r.invoice_amount invoiceAmount,
        r.tax_amount taxAmount,
        r.total_amount totalAmount,
        r.invoice_status invoiceStatus,
        r.dqskssq,
        r.source_system sourceSystem,
        r.departure_city departureCity,
        r.reaching_city reachingCity,
        r.related_business_documents relatedBusinessDocumes,
        r.business_document_maker businessDocumentMaker,
        r.business_document_number businessDocumentNumber,
        r.reimbursement_time reimbursementTime,
        r.reimbursement_status reimbursementStatus,
        r.train_number trainNumber,
        r.ticket_departure_time ticketDepartureTime,
        r.ticket_arrival_time ticketArrivalTime,
        r.passenger_s_f_z_h passengerSfzh,
        r.uuid,
        r.gf_tax_no gfTaxNo,
        r.gf_address_and_phone gfAddressAndPhone,
        r.gf_bank_and_no gfBankAndNo,
        r.xf_address_and_phone xfAddressAndPhone,
        r.xf_bank_and_no xfBankAndNo,
        r.gf_name gfName,
        r.xf_tax_no xfTaxNo,
        r.xf_name xfName,
        r.tax_rate taxRate,
        date_format(r.create_date,'%Y-%m-%d') createDate,
        r.rzh_yesorno rzhYesorno,
        r.tag,
        r.is_deduction isDeduction,
        r.is_domestic isDomestic,
        r.select_id selectId,
        r.qs_date qsDate,
        r.qs_type qsType,
        r.qs_name qsName,
        r.qs_status qsStatus,
        r.scan_id scanId,
        t.invoice_remark remark,
        '1' fileType,
        r.check_code checkCode,
        r.qz_status qzStatus,
        r.ewm,
        r.orientation,
        r.region,
        r.fuel_surcharge fuelSurcharge,
        r.caac_development_fund caacDevelopmentFund,
        r.update_date updateDate,
        r.fare,
        r.notes,
        r.dept_name businessName,
        '1' isHunsao
        from t_dx_invoice_reimburse r left join t_dx_invoice t on r.uuid = t.uuid
        where r.qs_name = #{param.userName} and (r.qs_status='1' or (r.qs_status='0' and (t.qs_status ='0' or
        t.qs_status is null)))
        <if
                test="param.invoiceType != '99' and param.invoiceType != null and param.invoiceType != '' and param.invoiceType != 'null'">
            and r.invoice_type = #{param.invoiceType}
        </if>
        <if
                test="param.fileType != '99' and param.fileType != null and param.fileType != '' and param.fileType != 'null'">
            and r.file_type = #{param.fileType}
        </if>
        <if
                test="param.businessCode != '99' and param.businessCode != null and param.businessCode != '' and param.businessCode != 'null'">
            and r.dept_id = #{param.businessCode}
        </if>
        <if test="param.businessCode == ''">
            and (r.dept_id is null or r.dept_id='' or r.dept_id='99')
        </if>
        <if
                test="param.createDateBegin != null and param.createDateBegin != '' and param.createDateBegin != 'null' ">
            <![CDATA[ AND r.create_date >= #{param.createDateBegin} ]]>
        </if>
        <if
                test="param.createDateEnd != null and param.createDateEnd != '' and param.createDateEnd != 'null' ">
            <![CDATA[ AND r.create_date <= #{param.createDateEnd} ]]>
        </if>
        <if test="param.xfName != null and param.xfName != ''">
            and r.xf_name LIKE concat(#{param.xfName},'%')
        </if>
        <if test="param.ewm != null and param.ewm != ''">
            and r.ewm LIKE concat(#{param.ewm},'%')
        </if>
        <if test="param.qzStatus != null and param.qzStatus != '' and param.qzStatus != '99'">
            and r.qz_status = #{param.qzStatus}
        </if>
        <if test="param.gfsh != null and param.gfsh != '' and param.gfsh != '99'">
            and r.gf_tax_no = #{param.gfsh}
        </if>
        <if test="param.qsStatus != null and param.qsStatus != '' and param.qsStatus != '99'">
            and r.qs_status = #{param.qsStatus}
        </if>
        ) t order by t.createDate desc

    </select>
    <select id="selectQsfpList" parameterType="java.util.Map"
            resultType="com.dxhy.portrait.business.entity.SmyqsWqsfpVO" databaseId="oracle">
        select * from (
        select
        t.id,
        t.invoice_type invoiceType,
        t.invoice_code invoiceCode,
        t.invoice_no invoiceNo,
        to_char(t.invoice_date,'yyyy-MM-dd') invoiceDate,
        r.ticket_number ticketNumber,
        r.passenger,
        t.invoice_amount invoiceAmount,
        t.tax_amount taxAmount,
        t.total_amount totalAmount,
        t.invoice_status invoiceStatus,
        r.dqskssq,
        r.source_system sourceSystem,
        r.departure_city departureCity,
        r.reaching_city reachingCity,
        r.related_business_documents relatedBusinessDocumes,
        r.business_document_maker businessDocumentMaker,
        r.business_document_number businessDocumentNumber,
        r.reimbursement_time reimbursementTime,
        r.reimbursement_status reimbursementStatus,
        r.train_number trainNumber,
        r.ticket_departure_time ticketDepartureTime,
        r.ticket_arrival_time ticketArrivalTime,
        r.passenger_s_f_z_h passengerSfzh,
        t.uuid,
        t.gf_tax_no gfTaxNo,
        r.gf_address_and_phone gfAddressAndPhone,
        r.gf_bank_and_no gfBankAndNo,
        r.xf_address_and_phone xfAddressAndPhone,
        r.xf_bank_and_no xfBankAndNo,
        t.gf_name gfName,
        t.xf_tax_no xfTaxNo,
        t.xf_name xfName,
        r.tax_rate taxRate,
        to_char(t.create_date,'yyyy-MM-dd') createDate,
        r.rzh_yesorno rzhYesorno,
        r.tag,
        r.is_deduction isDeduction,
        r.is_domestic isDomestic,
        r.select_id selectId,
        t.qs_date qsDate,
        t.qs_type qsType,
        t.qs_name qsName,
        t.qs_status qsStatus,
        t.scan_id scanId,
        t.invoice_remark remark,
        '1' fileType,
        t.check_code checkCode,
        r.qz_status qzStatus,
        r.ewm,
        r.orientation,
        r.region,
        r.fuel_surcharge fuelSurcharge,
        r.caac_development_fund caacDevelopmentFund,
        t.update_date updateDate,
        r.fare,
        t.notes,
        t.dept_name businessName,
        '0'isHunsao
        from t_dx_invoice t left join t_dx_invoice_reimburse r on t.uuid = r.uuid
        where t.user_name=#{param.userName} and ((t.qs_status='0' and r.id is null) or (t.qs_status='1' and
        (r.qs_status!='1' or r.qs_status is null)))
        <if
                test="param.invoiceType != '99' and param.invoiceType != null and param.invoiceType != '' and param.invoiceType != 'null'">
            and t.invoice_type = #{param.invoiceType}
        </if>
        <if
                test="param.fileType != '99' and param.fileType != null and param.fileType != '' and param.fileType != 'null'">
            and r.file_type = #{param.fileType}
        </if>
        <if
                test="param.businessCode != '99' and param.businessCode != null and param.businessCode != '' and param.businessCode != 'null'">
            and t.dept_id = #{param.businessCode}
        </if>
        <if test="param.businessCode == ''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if
                test="param.createDateBegin != null and param.createDateBegin != '' and param.createDateBegin != 'null' ">
            <![CDATA[ AND to_char(t.create_date,'yyyy-MM-dd HH24:mm:dd') >= #{param.createDateBegin} ]]>
        </if>
        <if
                test="param.createDateEnd != null and param.createDateEnd != '' and param.createDateEnd != 'null' ">
            <![CDATA[ AND to_char(t.create_date,'yyyy-MM-dd HH24:mm:dd') <= #{param.createDateEnd} ]]>
        </if>
        <if test="param.xfName != null and param.xfName != ''">
            and t.xf_name LIKE concat(#{param.xfName},'%')
        </if>
        <if test="param.ewm != null and param.ewm != ''">
            and r.ewm LIKE concat(#{param.ewm},'%')
        </if>
        <if test="param.qzStatus != null and param.qzStatus != '' and param.qzStatus != '99'">
            and r.qz_status = #{param.qzStatus}
        </if>
        <if test="param.gfsh != null and param.gfsh != '' and param.gfsh != '99'">
            and t.gf_tax_no = #{param.gfsh}
        </if>
        <if test="param.qsStatus != null and param.qsStatus != '' and param.qsStatus != '99'">
            and t.qs_status = #{param.qsStatus}
        </if>

        union all
        select
        r.id,
        r.invoice_type invoiceType,
        r.invoice_code invoiceCode,
        r.invoice_no invoiceNo,
        to_char(r.invoice_date,'yyyy-MM-dd') invoiceDate,
        r.ticket_number ticketNumber,
        r.passenger,
        r.invoice_amount invoiceAmount,
        r.tax_amount taxAmount,
        r.total_amount totalAmount,
        r.invoice_status invoiceStatus,
        r.dqskssq,
        r.source_system sourceSystem,
        r.departure_city departureCity,
        r.reaching_city reachingCity,
        r.related_business_documents relatedBusinessDocumes,
        r.business_document_maker businessDocumentMaker,
        r.business_document_number businessDocumentNumber,
        r.reimbursement_time reimbursementTime,
        r.reimbursement_status reimbursementStatus,
        r.train_number trainNumber,
        r.ticket_departure_time ticketDepartureTime,
        r.ticket_arrival_time ticketArrivalTime,
        r.passenger_s_f_z_h passengerSfzh,
        r.uuid,
        r.gf_tax_no gfTaxNo,
        r.gf_address_and_phone gfAddressAndPhone,
        r.gf_bank_and_no gfBankAndNo,
        r.xf_address_and_phone xfAddressAndPhone,
        r.xf_bank_and_no xfBankAndNo,
        r.gf_name gfName,
        r.xf_tax_no xfTaxNo,
        r.xf_name xfName,
        r.tax_rate taxRate,
        to_char(r.create_date,'yyyy-MM-dd') createDate,
        r.rzh_yesorno rzhYesorno,
        r.tag,
        r.is_deduction isDeduction,
        r.is_domestic isDomestic,
        r.select_id selectId,
        r.qs_date qsDate,
        r.qs_type qsType,
        r.qs_name qsName,
        r.qs_status qsStatus,
        r.scan_id scanId,
        t.invoice_remark remark,
        '1' fileType,
        r.check_code checkCode,
        r.qz_status qzStatus,
        r.ewm,
        r.orientation,
        r.region,
        r.fuel_surcharge fuelSurcharge,
        r.caac_development_fund caacDevelopmentFund,
        r.update_date updateDate,
        r.fare,
        r.notes,
        r.dept_name businessName,
        '1' isHunsao
        from t_dx_invoice_reimburse r left join t_dx_invoice t on r.uuid = t.uuid
        where r.qs_name = #{param.userName} and (r.qs_status='1' or (r.qs_status='0' and (t.qs_status ='0' or
        t.qs_status is null)))
        <if
                test="param.invoiceType != '99' and param.invoiceType != null and param.invoiceType != '' and param.invoiceType != 'null'">
            and r.invoice_type = #{param.invoiceType}
        </if>
        <if
                test="param.fileType != '99' and param.fileType != null and param.fileType != '' and param.fileType != 'null'">
            and r.file_type = #{param.fileType}
        </if>
        <if
                test="param.businessCode != '99' and param.businessCode != null and param.businessCode != '' and param.businessCode != 'null'">
            and r.dept_id = #{param.businessCode}
        </if>
        <if test="param.businessCode == ''">
            and (r.dept_id is null or r.dept_id='' or r.dept_id='99')
        </if>
        <if
                test="param.createDateBegin != null and param.createDateBegin != '' and param.createDateBegin != 'null' ">
            <![CDATA[ AND to_char(r.create_date,'yyyy-MM-dd HH24:mm:dd') >= #{param.createDateBegin} ]]>
        </if>
        <if
                test="param.createDateEnd != null and param.createDateEnd != '' and param.createDateEnd != 'null' ">
            <![CDATA[ AND to_char(r.create_date,'yyyy-MM-dd HH24:mm:dd') <= #{param.createDateEnd} ]]>
        </if>
        <if test="param.xfName != null and param.xfName != ''">
            and r.xf_name LIKE concat(#{param.xfName},'%')
        </if>
        <if test="param.ewm != null and param.ewm != ''">
            and r.ewm LIKE concat(#{param.ewm},'%')
        </if>
        <if test="param.qzStatus != null and param.qzStatus != '' and param.qzStatus != '99'">
            and r.qz_status = #{param.qzStatus}
        </if>
        <if test="param.gfsh != null and param.gfsh != '' and param.gfsh != '99'">
            and r.gf_tax_no = #{param.gfsh}
        </if>
        <if test="param.qsStatus != null and param.qsStatus != '' and param.qsStatus != '99'">
            and r.qs_status = #{param.qsStatus}
        </if>
        ) t order by t.createDate desc

    </select>
</mapper>
