tdhmapper.xml 5.91 KB
Newer Older
hulei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
<?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.brilliance.isc.mda.dao.TdhMapper">
    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Tdh">
        <result property="inr" column="INR" jdbcType="VARCHAR"/>
        <result property="cur" column="CUR" jdbcType="VARCHAR"/>
        <result property="datesource" column="DATESOURCE" jdbcType="VARCHAR"/>
        <result property="dat" column="DAT" jdbcType="TIMESTAMP"/>
        <result property="dateday" column="DATEDAY" jdbcType="VARCHAR"/>
        <result property="datStr" column="DAT_STR" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="VoResultMap" type="com.brilliance.isc.vo.manager.TdhVo">
        <result property="inr" column="INR" jdbcType="VARCHAR"/>
        <result property="cur" column="CUR" jdbcType="VARCHAR"/>
        <result property="curname" column="curname" jdbcType="VARCHAR"/>
        <result property="datesource" column="DATESOURCE" jdbcType="VARCHAR"/>
        <result property="dat" column="DAT" jdbcType="TIMESTAMP"/>
        <result property="dateday" column="DATEDAY" jdbcType="VARCHAR"/>
        <result property="datStr" column="DAT_STR" jdbcType="VARCHAR"/>
    </resultMap>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="BaseResultMap">
        select
        INR, CUR, DATESOURCE, DAT, DATEDAY, date_format(DAT, '%Y-%m-%d') DAT_STR
        from TDH
        <where>
            <if test="cur != null and cur != ''">
                AND CUR like concat(concat ('%',#{cur}),'%')
            </if>
            <if test="dat != null and dat != ''">
                and DAT like concat(concat ('%',#{dat}),'%')
            </if>
        </where>
        ORDER BY DAT
    </select>

    <!--查询单个-->
    <select id="queryByCurAndDat" resultMap="BaseResultMap">
        select
          INR, CUR, DATESOURCE, DAT, DATEDAY,date_format(DAT, '%Y-%m-%d') DAT_STR
        from TDH
        where DAT = #{dat} and CUR = #{cur}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from TDH
        <where>
            <if test="inr != null and inr != ''">
                AND INR = #{inr}
            </if>
            <if test="cur != null and cur != ''">
                AND CUR = #{cur}
            </if>
            <if test="datesource != null and datesource != ''">
                AND DATESOURCE = #{datesource}
            </if>
            <if test="dat != null">
                AND DAT = #{dat}
            </if>
            <if test="dateday != null and dateday != ''">
                AND DATEDAY = #{dateday}
            </if>
        </where>
    </select>

    <select id="check" resultType="java.lang.Long">
        select count(1)
        from TDH
        <where>
            <if test="dat != null">
                AND DAT = #{dat}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="inr" useGeneratedKeys="true">
        insert into TDH(INR, CUR, DATESOURCE, DAT, DATEDAY)
        values (#{inr}, #{cur}, #{datesource}, #{dat}, #{dateday})
    </insert>

    <!--批量导入-->
    <insert id="insertBatch" keyProperty="" useGeneratedKeys="true">
        insert into TDH(INR,CUR,DAT,DATESOURCE,DATEDAY)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.inr}, #{entity.cur}, #{entity.dat}, #{entity.datesource}, #{entity.dateday})
        </foreach>
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update TDH
        <set>
            <if test="cur != null and cur != ''">
                CUR = #{cur},
            </if>
            <if test="datesource != null and datesource != ''">
                DATESOURCE = #{datesource},
            </if>
            <if test="dat != null">
                DAT = #{dat},
            </if>
            <if test="dateday != null and dateday != ''">
                DATEDAY = #{dateday},
            </if>
        </set>
        where INR = #{inr}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from TDH where inr = #{inr}
    </delete>

    <!--查询指定行数据-->
    <select id="queryDat" resultMap="BaseResultMap">
        select
        INR, CUR, DATESOURCE, DAT, DATEDAY, date_format(DAT, '%Y-%m-%d') DAT_STR
        from TDH
        <where>
            <if test="begdat != null">
                and DAT <![CDATA[>=]]> #{begdat,jdbcType=DATE}
            </if>
            <if test="enddat != null">
                and DAT <![CDATA[<=]]> #{enddat,jdbcType=DATE}
            </if>
        </where>
        ORDER BY DAT
    </select>

    <select id="queryByDat" resultMap="BaseResultMap">
        select
        INR, CUR, DATESOURCE, DAT, DATEDAY, date_format(DAT, '%Y-%m-%d') DAT_STR
        from TDH where Dat=#{dat}
    </select>

    <select id="listTdh" resultMap="VoResultMap">
hulei committed
143
        select a.INR INR, a.CUR CUR,concat (a.cur,' - ',b.TXT) curname, a.DATESOURCE DATESOURCE, a.DAT DAT, a.DATEDAY DATEDAY,
hulei committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
        date_format(a.DAT, '%Y-%m-%d') DAT_STR from TDH a left join stb b on b.TBL = 'CURTXT' and a.CUR = b.COD and b.UIL = 'EN'
        <where>
            <choose>
                <when test="cur != null and cur != ''">
                    a.CUR like concat(concat ('%',#{cur}),'%')
                </when>
                <otherwise>
                    a.CUR in ('CNY','USD','EUR','GBP','JPY','HKD')
                </otherwise>
            </choose>
            <if test="dat != null and dat != ''">
                and a.DAT like concat(concat ('%',#{dat}),'%')
            </if>
        </where>
        order by b.SRT ,a.DAT
    </select>

    <select id="getCurName" resultType="java.lang.String">
        select concat (s.cod,' - ',s.TXT) curname from stb s where s.TBL = 'CURTXT'  and s.UIL  = 'EN' and s.cod = #{cur}
    </select>


</mapper>