NavMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.simuwang.base.mapper.daq.NavMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.NavDO">
  5. <id column="id" property="id"/>
  6. <result column="fund_id" property="fundId"/>
  7. <result column="price_date" property="priceDate"/>
  8. <result column="nav" property="nav"/>
  9. <result column="cumulative_nav" property="cumulativeNav"/>
  10. <result column="cumulative_nav_withdrawal" property="cumulativeNavWithdrawal"/>
  11. <result column="isvalid" property="isvalid"/>
  12. <result column="creatorid" property="creatorId"/>
  13. <result column="createtime" property="createTime"/>
  14. <result column="updaterid" property="updaterId"/>
  15. <result column="updatetime" property="updateTime"/>
  16. <result column="channel_id" property="channelId"/>
  17. </resultMap>
  18. <insert id="batchInsert" parameterType="com.simuwang.base.pojo.dos.NavDO">
  19. insert into nav(fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  20. isvalid, creatorid, createtime, updaterid, updatetime,channel_id)
  21. values
  22. <foreach collection="itemDoList" item="itemDo" index="index" separator=",">
  23. (#{itemDo.fundId},#{itemDo.priceDate},#{itemDo.nav},#{itemDo.cumulativeNav},#{itemDo.cumulativeNavWithdrawal},
  24. #{itemDo.isvalid}, #{itemDo.creatorId}, #{itemDo.createTime}, #{itemDo.updaterId}, #{itemDo.updateTime}, #{itemDo.channelId})
  25. </foreach>
  26. </insert>
  27. <insert id="batchUpdate">
  28. <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
  29. update nav
  30. <set>
  31. nav = #{itemDo.nav},
  32. cumulative_nav_withdrawal = #{itemDo.cumulativeNavWithdrawal},
  33. updatetime=#{itemDo.updateTime}
  34. </set>
  35. where isvalid = 1
  36. and fund_id = #{itemDo.fundId}
  37. and price_date = #{itemDo.priceDate}
  38. and channel_id = #{itemDo.channelId}
  39. </foreach>
  40. </insert>
  41. <insert id="saveNav" parameterType="com.simuwang.base.pojo.dos.NavDO">
  42. insert into nav(fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  43. isvalid, creatorid, createtime, updaterid, updatetime,channel_id)
  44. values
  45. (#{fundId},#{priceDate},#{nav},#{cumulativeNav},#{cumulativeNavWithdrawal},
  46. #{isvalid}, #{creatorId}, #{createTime}, #{updaterId}, #{updateTime},#{channelId})
  47. </insert>
  48. <update id="updateNav" parameterType="com.simuwang.base.pojo.dos.NavDO">
  49. update nav
  50. <set>
  51. nav = #{nav},
  52. cumulative_nav_withdrawal = #{cumulativeNavWithdrawal},
  53. updatetime=#{updateTime},
  54. updaterid=#{updaterId}
  55. </set>
  56. where isvalid = 1
  57. and id=#{id}
  58. </update>
  59. <update id="batchDeleteNav">
  60. update nav set isvalid=0,updatetime=now() where fund_id=#{fundId}
  61. and price_date in
  62. <foreach collection="priceDateList" index="index" item="priceDate" separator="," open="(" close=")">
  63. #{priceDate}
  64. </foreach>
  65. </update>
  66. <delete id="deleteNav">
  67. update nav set isvalid=0,updatetime=now(),updaterid=#{updaterId} where fund_id=#{fundId} and price_date=#{priceDate}
  68. </delete>
  69. <select id="queryFundNavByDate" resultType="java.lang.String">
  70. select price_date
  71. from nav
  72. where isvalid = 1
  73. and fund_id = #{fundId}
  74. and price_date in
  75. <foreach collection="priceDateList" index="index" item="priceDate" separator="," open="(" close=")">
  76. #{priceDate}
  77. </foreach>
  78. <if test="channelId != null and channelId !='">
  79. channel_id=#{channnelId}
  80. </if>
  81. </select>
  82. <select id="queryFundNav" resultMap="BaseResultMap"
  83. parameterType="com.simuwang.base.pojo.dos.NavDO">
  84. SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  85. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  86. from nav
  87. where isvalid = 1
  88. and fund_id = #{fundId}
  89. and price_date=#{priceDate}
  90. <if test="channelId != null and channelId !=''">
  91. and channel_id=#{channelId}
  92. </if>
  93. </select>
  94. <select id="getAllFundId" resultType="java.lang.String">
  95. select fund_id from nav where isvalid=1 group by fund_id
  96. </select>
  97. <select id="selectNavByFundId" resultMap="BaseResultMap"
  98. parameterType="java.lang.String">
  99. SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  100. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  101. from nav
  102. where isvalid = 1
  103. and fund_id = #{fundId}
  104. order by price_date
  105. </select>
  106. <select id="countNavTotal" resultType="java.lang.Long">
  107. select count(1) from nav where isvalid=1
  108. </select>
  109. <select id="queryNavByFundIdDate" resultMap="BaseResultMap">
  110. SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  111. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  112. from nav
  113. where isvalid = 1
  114. and fund_id = #{fundId} and price_date = #{priceDate}
  115. <if test="channelId != null and channelId !=''">
  116. and channel_id=#{channelId}
  117. </if>
  118. order by price_date desc
  119. limit 1
  120. </select>
  121. <select id="queryLastNavByFundIdDate" resultMap="BaseResultMap">
  122. SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  123. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  124. from nav
  125. where isvalid = 1
  126. and fund_id = #{fundId} and price_date <![CDATA[ < ]]> #{priceDate}
  127. <if test="channelId != null and channelId !=''">
  128. and channel_id=#{channelId}
  129. </if>
  130. order by price_date desc
  131. limit 1
  132. </select>
  133. <select id="selectNavByChannelId" resultMap="BaseResultMap">
  134. SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  135. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  136. from nav
  137. where isvalid = 1
  138. and channel_id = #{channelId}
  139. order by price_date
  140. </select>
  141. <select id="selectNavByFundIdAndDate" resultMap="BaseResultMap">
  142. SELECT id, fund_id,price_date,nav,cumulative_nav,cumulative_nav_withdrawal,
  143. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  144. from nav
  145. where isvalid = 1
  146. and fund_id = #{fundId} and price_date >= #{priceDate}
  147. group by fund_id,price_date
  148. </select>
  149. <select id="selectMaxPriceDate" resultType="java.util.Date">
  150. select max(price_date) from nav where channel_id = #{channelId} and fund_id = #{fundId} and isvalid=1
  151. </select>
  152. </mapper>