<?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.saye.hospitalgd.mapper.BankbillsHistoryMapper">

    <select id="findBankbillHistoryByParam" parameterType="HashMap" resultType="HashMap">
        select
        I_JYRQ
        ,I_JYSJ
        ,I_JZRQ
        ,I_YHLSH
        ,I_SHLSH
        ,I_DDH
        ,I_DDZT
        ,I_FKFZH
        ,I_FKFHM
        ,I_DDJE
        ,I_JYJE
        ,I_SXF
        ,I_JSJE
        ,I_GTDM
        ,I_FXK
        ,I_ZFKZ
        ,I_JYLX
        ,I_QS

        from bankbills_history
        where I_JYRQ = #{trade_date}
        <if test="i_ddh!=null and i_ddh!=''">
            and I_DDH=#{i_ddh}
        </if>
        <if test="i_jylx!=null and i_jylx!=''">
            and I_JYLX=#{i_jylx}
        </if>

        <if test="orderby_je!=null and orderby_je!=''">
            order by I_JYJE desc
        </if>
    </select>
    <select id="findBankBillsByDate" parameterType="HashMap" resultType="HashMap">
        select I_JYRQ
             , I_JYSJ
             , I_JZRQ
             , I_YHLSH
             , I_SHLSH
             , I_DDH
             , I_DDZT
             , I_FKFZH
             , I_FKFHM
             , I_DDJE
             , I_JYJE
             , I_SXF
             , I_JSJE
             , I_GTDM
             , I_FXK
             , I_ZFKZ
             , I_JYLX
             , I_QS

        from bankbills_history
        where I_JYRQ = #{trade_date}
    </select>
    <insert id="saveOriginalData" parameterType="java.util.List">
        insert into bankbills_original (
        I_JYRQ
        ,I_JYSJ
        ,I_JZRQ
        ,I_YHLSH
        ,I_SHLSH
        ,I_DDH
        ,I_DDZT
        ,I_FKFZH
        ,I_FKFHM
        ,I_DDJE
        ,I_JYJE
        ,I_SXF
        ,I_JSJE
        ,I_GTDM
        ,I_FXK
        ,I_ZFKZ
        ,I_JYLX
        ,I_QS
        ) values
        <foreach collection="list" index="index" item="itm" separator=",">
            (
            #{itm.i_jyrq},#{itm.i_jysj},#{itm.i_jzrq},#{itm.i_yhlsh},#{itm.i_shlsh},#{itm.i_ddh},#{itm.i_ddzt},#{itm.i_fkfzh},#{itm.i_fkfhm},#{itm.i_ddje},#{itm.i_jyje},#{itm.i_sxf},#{itm.i_jsje}
            ,#{itm.i_gtdm},#{itm.i_fxk},#{itm.i_zfkz},#{itm.i_jylx},#{itm.i_qs}
            )
        </foreach>
    </insert>
    <insert id="saveHistoryData" parameterType="java.util.List">
        insert into bankbills_history (
        I_JYRQ
        ,I_JYSJ
        ,I_JZRQ
        ,I_YHLSH
        ,I_SHLSH
        ,I_DDH
        ,I_DDZT
        ,I_FKFZH
        ,I_FKFHM
        ,I_DDJE
        ,I_JYJE
        ,I_SXF
        ,I_JSJE
        ,I_GTDM
        ,I_FXK
        ,I_ZFKZ
        ,I_JYLX
        ,I_QS
        ) values
        <foreach collection="list" index="index" item="itm" separator=",">
            (
            #{itm.i_jyrq},#{itm.i_jysj},#{itm.i_jzrq},#{itm.i_yhlsh},#{itm.i_shlsh},#{itm.i_ddh},#{itm.i_ddzt},#{itm.i_fkfzh},#{itm.i_fkfhm},#{itm.i_ddje},#{itm.i_jyje},#{itm.i_sxf},#{itm.i_jsje}
            ,#{itm.i_gtdm},#{itm.i_fxk},#{itm.i_zfkz},#{itm.i_jylx},#{itm.i_qs}
            )
        </foreach>
    </insert>

    <delete id="deleteOriginalByParam" parameterType="HashMap">
        delete
        from bankbills_original
        where I_JYRQ = #{trade_date}
    </delete>
    <insert id="insertOriginal" parameterType="HashMap">
        insert into
        bankbills_original(
        I_DZDRQ
        ,I_JTBH
        ,I_JTMC
        ,I_TYDWBH
        ,I_TYDWMC
        ,I_WXBH
        ,I_ZFBBH
        ,I_XSXXBZ
        ,I_JYRQ
        ,I_JYSJ
        ,I_SHRZZH
        ,I_POSBH
        ,I_JYLX
        ,I_JYQD
        ,I_JYFS
        ,I_GHDDH
        ,I_SHDDH
        ,I_DSFDDH
        ,I_GLDDH
        ,I_SXFQSFS
        ,I_DDZJE
        ,I_JYJE
        ,I_RZJE
        ,I_FKKH
        ,I_FKYH
        ,I_JDJBZ
        ,I_YHBS
        ,I_HBZL
        ,I_SHMC
        ,I_FY
        )
        values
        <foreach collection="list" index="index" item="itm" separator=",">
            (
            #{itm.iDzdrq},#{itm.iJtbh},#{itm.iJtmc},#{itm.iTydwbh},#{itm.iTydwmc},#{itm.iWxbh},#{itm.iZfbbh},#{itm.iXsxxbz},#{itm.iJyrq},#{itm.iJysj},#{itm.iShrzzh},#{itm.iPosbh},#{itm.iJylx}
            ,#{itm.iJyqd},#{itm.iJyfs},#{itm.iGhddh},#{itm.iShddh},#{itm.iDsfddh},#{itm.iGlddh},#{itm.iSxfqsfs},#{itm.iDdzje}
            ,#{itm.iJyje},#{itm.iRzje},#{itm.iFkkh},#{itm.iFkyh},#{itm.iJdjbz},#{itm.iYhbs},#{itm.iHbzl},#{itm.iSpmc},#{itm.iFy})
        </foreach>
    </insert>

    <!--删除记录-->
    <delete id="deleteHistoryByParam" parameterType="HashMap">
        delete
        from bankbills_history
        where I_JYRQ = #{trade_date}
    </delete>
    <!--批量插入银行交易记录-->
    <insert id="insertHistory" parameterType="java.util.List">
        insert into
        bankbills_history(
        I_DZDRQ
        ,I_JTBH
        ,I_JTMC
        ,I_TYDWBH
        ,I_TYDWMC
        ,I_WXBH
        ,I_ZFBBH
        ,I_XSXXBZ
        ,I_JYRQ
        ,I_JYSJ
        ,I_SHRZZH
        ,I_POSBH
        ,I_JYLX
        ,I_JYQD
        ,I_JYFS
        ,I_GHDDH
        ,I_SHDDH
        ,I_DSFDDH
        ,I_GLDDH
        ,I_SXFQSFS
        ,I_DDZJE
        ,I_JYJE
        ,I_RZJE
        ,I_FKKH
        ,I_FKYH
        ,I_JDJBZ
        ,I_YHBS
        ,I_HBZL
        ,I_SHMC
        ,I_FY)
        values
        <foreach collection="list" index="index" item="itm" separator=",">
            (
            #{itm.iDzdrq},#{itm.iJtbh},#{itm.iJtmc},#{itm.iTydwbh},#{itm.iTydwmc},#{itm.iWxbh},#{itm.iZfbbh},#{itm.iXsxxbz},#{itm.iJyrq},#{itm.iJysj},#{itm.iShrzzh},#{itm.iPosbh},#{itm.iJylx}
            ,#{itm.iJyqd},#{itm.iJyfs},#{itm.iGhddh},#{itm.iShddh},#{itm.iDsfddh},#{itm.iGlddh},#{itm.iSxfqsfs},#{itm.iDdzje}
            ,#{itm.iJyje},#{itm.iRzje},#{itm.iFkkh},#{itm.iFkyh},#{itm.iJdjbz},#{itm.iYhbs},#{itm.iHbzl},#{itm.iSpmc},#{itm.iFy})
        </foreach>
    </insert>

</mapper>