FundNavAssetMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.FundNavAssetMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.FundNavAssetDO">
  5. <result column="fund_id" property="fundId"/>
  6. <result column="fund_short_name" property="fundName"/>
  7. <result column="register_number" property="registerNumber"/>
  8. <result column="price_date" property="priceDate"/>
  9. <result column="nav" property="nav"/>
  10. <result column="cumulative_nav_withdrawal" property="cumulativeNavWithdrawal"/>
  11. <result column="asset_share" property="assetShare"/>
  12. <result column="asset_net" property="assetNet"/>
  13. <result column="updatetime" property="updateTime"/>
  14. </resultMap>
  15. <select id="searchNavAssetList" resultMap="BaseResultMap"
  16. parameterType="com.simuwang.base.pojo.dto.query.FundNavAssetPageQuery">
  17. SELECT distinct
  18. info.fund_id,
  19. info.fund_short_name,
  20. info.register_number,
  21. IFNULL(
  22. nav.price_date,
  23. asset.price_date
  24. ) AS price_date,
  25. nav.nav,
  26. nav.cumulative_nav_withdrawal,
  27. asset.asset_share,
  28. asset.asset_net,
  29. CASE
  30. WHEN nav.updatetime is null
  31. THEN asset.updatetime
  32. WHEN asset.updatetime is null
  33. THEN nav.updatetime
  34. WHEN asset.updatetime >= nav.updatetime
  35. THEN asset.updatetime
  36. ELSE nav.updatetime
  37. END AS updatetime
  38. FROM
  39. PPW_EMAIL.pvn_fund_info info
  40. LEFT JOIN PPW_EMAIL.nav nav
  41. ON info.fund_id = nav.fund_id
  42. AND nav.isvalid = 1
  43. LEFT JOIN PPW_EMAIL.asset asset
  44. ON info.fund_id = asset.fund_id
  45. AND nav.price_date = asset.price_date
  46. AND asset.isvalid = 1
  47. WHERE info.isvalid = 1
  48. and (nav.nav is not null or asset.asset_share is not null or asset.asset_net is not null)
  49. <if test="fundName != null and fundName !=''">
  50. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.register_number like concat('%',#{fundName},'%'))
  51. </if>
  52. <if test="priceStartDate != null and priceStartDate !=''">
  53. and (nav.price_date >= #{priceStartDate} or asset.price_date >= #{priceStartDate})
  54. </if>
  55. <if test="priceEndDate != null and priceEndDate !=''">
  56. and (nav.price_date <![CDATA[ <= ]]> #{priceEndDate} or asset.price_date <![CDATA[ <= ]]> #{priceEndDate})
  57. </if>
  58. <if test="updateStartDate != null and updateStartDate !=''">
  59. and (nav.updatetime >= #{updateStartDate} or asset.updatetime >= #{updateStartDate})
  60. </if>
  61. <if test="updateEndDate != null and updateEndDate !=''">
  62. and (nav.updatetime <![CDATA[ <= ]]> #{updateEndDate} or asset.updatetime <![CDATA[ <= ]]> #{updateEndDate})
  63. </if>
  64. <choose>
  65. <when test="sort != null and sort !='' and sort=='priceDate' and order != null and order !=''">
  66. order by price_date ${order}
  67. </when>
  68. <otherwise>
  69. order by price_date desc
  70. </otherwise>
  71. </choose>
  72. limit #{offset},#{pageSize}
  73. </select>
  74. <select id="countNavAssetList" resultType="java.lang.Long"
  75. parameterType="com.simuwang.base.pojo.dto.query.FundNavAssetPageQuery">
  76. SELECT count(1)
  77. FROM
  78. PPW_EMAIL.pvn_fund_info info
  79. LEFT JOIN PPW_EMAIL.nav nav
  80. ON info.fund_id = nav.fund_id
  81. AND nav.isvalid = 1
  82. LEFT JOIN PPW_EMAIL.asset asset
  83. ON info.fund_id = asset.fund_id
  84. AND nav.price_date = asset.price_date
  85. AND asset.isvalid = 1
  86. WHERE info.isvalid = 1
  87. and (nav.nav is not null or asset.asset_share is not null or asset.asset_net is not null)
  88. <if test="fundName != null and fundName !=''">
  89. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.register_number like concat('%',#{fundName},'%'))
  90. </if>
  91. <if test="priceStartDate != null and priceStartDate !=''">
  92. and (nav.price_date >= #{priceStartDate} or asset.price_date >= #{priceStartDate})
  93. </if>
  94. <if test="priceEndDate != null and priceEndDate !=''">
  95. and (nav.price_date <![CDATA[ <= ]]> #{priceEndDate} or asset.price_date <![CDATA[ <= ]]> #{priceEndDate})
  96. </if>
  97. <if test="updateStartDate != null and updateStartDate !=''">
  98. and (nav.updatetime >= #{updateStartDate} or asset.updatetime >= #{updateStartDate})
  99. </if>
  100. <if test="updateEndDate != null and updateEndDate !=''">
  101. and (nav.updatetime <![CDATA[ <= ]]> #{updateEndDate} or asset.updatetime <![CDATA[ <= ]]> #{updateEndDate})
  102. </if>
  103. </select>
  104. </mapper>