123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?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.simuwang.base.mapper.daq.NavMapper">
- <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.NavDO">
- <id column="id" property="id"/>
- <result column="fund_id" property="fundId"/>
- <result column="price_date" property="priceDate"/>
- <result column="nav" property="nav"/>
- <result column="cumulative_nav" property="cumulativeNav"/>
- <result column="cumulative_nav_withdrawal" property="cumulativeNavWithdrawal"/>
- <result column="isvalid" property="isvalid"/>
- <result column="creatorid" property="creatorId"/>
- <result column="createtime" property="createTime"/>
- <result column="updaterid" property="updaterId"/>
- <result column="updatetime" property="updateTime"/>
- <result column="channel_id" property="channelId"/>
- </resultMap>
- <insert id="batchInsert" parameterType="com.simuwang.base.pojo.dos.NavDO">
- insert into nav(fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id)
- values
- <foreach collection="itemDoList" item="itemDo" index="index" separator=",">
- (#{itemDo.fundId},#{itemDo.priceDate},#{itemDo.nav},#{itemDo.cumulativeNav},#{itemDo.cumulativeNavWithdrawal},
- #{itemDo.isvalid}, #{itemDo.creatorId}, #{itemDo.createTime}, #{itemDo.updaterId}, #{itemDo.updateTime}, #{itemDo.channelId})
- </foreach>
- </insert>
- <insert id="batchUpdate">
- <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
- update nav
- <set>
- nav = #{itemDo.nav},
- cumulative_nav_withdrawal = #{itemDo.cumulativeNavWithdrawal},
- updatetime=#{itemDo.updateTime}
- </set>
- where isvalid = 1
- and fund_id = #{itemDo.fundId}
- and price_date = #{itemDo.priceDate}
- and channel_id = #{itemDo.channelId}
- </foreach>
- </insert>
- <insert id="saveNav" parameterType="com.simuwang.base.pojo.dos.NavDO">
- insert into nav(fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id)
- values
- (#{fundId},#{priceDate},#{nav},#{cumulativeNav},#{cumulativeNavWithdrawal},
- #{isvalid}, #{creatorId}, #{createTime}, #{updaterId}, #{updateTime},#{channelId})
- </insert>
- <update id="updateNav" parameterType="com.simuwang.base.pojo.dos.NavDO">
- update nav
- <set>
- nav = #{nav},
- cumulative_nav_withdrawal = #{cumulativeNavWithdrawal},
- updatetime=#{updateTime},
- updaterid=#{updaterId}
- </set>
- where isvalid = 1
- and id=#{id}
- </update>
- <update id="batchDeleteNav">
- update nav set isvalid=0,updatetime=now() where fund_id=#{fundId}
- and price_date in
- <foreach collection="priceDateList" index="index" item="priceDate" separator="," open="(" close=")">
- #{priceDate}
- </foreach>
- </update>
- <delete id="deleteNav">
- update nav set isvalid=0,updatetime=now(),updaterid=#{updaterId} where fund_id=#{fundId} and price_date=#{priceDate}
- </delete>
- <select id="queryFundNavByDate" resultType="java.lang.String">
- select price_date
- from nav
- where isvalid = 1
- and fund_id = #{fundId}
- and price_date in
- <foreach collection="priceDateList" index="index" item="priceDate" separator="," open="(" close=")">
- #{priceDate}
- </foreach>
- <if test="channelId != null and channelId !='">
- channel_id=#{channnelId}
- </if>
- </select>
- <select id="queryFundNav" resultMap="BaseResultMap"
- parameterType="com.simuwang.base.pojo.dos.NavDO">
- SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id
- from nav
- where isvalid = 1
- and fund_id = #{fundId}
- and price_date=#{priceDate}
- <if test="channelId != null and channelId !=''">
- and channel_id=#{channelId}
- </if>
- </select>
- <select id="getAllFundId" resultType="java.lang.String">
- select fund_id from nav where isvalid=1 group by fund_id
- </select>
- <select id="selectNavByFundId" resultMap="BaseResultMap"
- parameterType="java.lang.String">
- SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id
- from nav
- where isvalid = 1
- and fund_id = #{fundId}
- order by price_date
- </select>
- <select id="countNavTotal" resultType="java.lang.Long">
- select count(1) from nav where isvalid=1
- </select>
- <select id="queryNavByFundIdDate" resultMap="BaseResultMap">
- SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id
- from nav
- where isvalid = 1
- and fund_id = #{fundId} and price_date = #{priceDate}
- <if test="channelId != null and channelId !=''">
- and channel_id=#{channelId}
- </if>
- order by price_date desc
- limit 1
- </select>
- <select id="queryLastNavByFundIdDate" resultMap="BaseResultMap">
- SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id
- from nav
- where isvalid = 1
- and fund_id = #{fundId} and price_date <![CDATA[ < ]]> #{priceDate}
- <if test="channelId != null and channelId !=''">
- and channel_id=#{channelId}
- </if>
- order by price_date desc
- limit 1
- </select>
- <select id="selectNavByChannelId" resultMap="BaseResultMap">
- SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id
- from nav
- where isvalid = 1
- and channel_id = #{channelId}
- order by price_date
- </select>
- <select id="selectNavByFundIdAndDate" resultMap="BaseResultMap">
- SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
- isvalid, creatorid, createtime, updaterid, updatetime,channel_id
- from nav
- where isvalid = 1
- and fund_id = #{fundId} and price_date >= #{priceDate}
- group by fund_id,price_date
- </select>
- <select id="selectMaxPriceDate" resultType="java.util.Date">
- select max(price_date) from nav where channel_id = #{channelId} and fund_id = #{fundId} and isvalid=1
- </select>
- </mapper>
|