FundInfoMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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.FundInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.FundInfoDO">
  5. <id column="id" property="id"/>
  6. <result column="p_fund_id" property="pFundId"/>
  7. <result column="fund_name" property="fundName"/>
  8. <result column="fund_short_name" property="fundShortName"/>
  9. <result column="fund_type" property="fundType"/>
  10. <result column="manager_type" property="managerType"/>
  11. <result column="base_currency" property="baseCurrency"/>
  12. <result column="inception_date" property="inceptionDate"/>
  13. <result column="advisor_id" property="advisorId"/>
  14. <result column="issuer_id" property="issuerId"/>
  15. <result column="issuer_company_name" property="issuerCompanyName"/>
  16. <result column="advisor_company_name" property="advisorCompanyName"/>
  17. <result column="custodian_id" property="custodianId"/>
  18. <result column="register_number" property="registerNumber"/>
  19. <result column="register_date" property="registerDate"/>
  20. <result column="is_amac_show" property="isAmacShow"/>
  21. <result column="fund_status" property="fundStatus"/>
  22. <result column="amac_source_type" property="amacSourceType"/>
  23. <result column="investment_type" property="investmentType"/>
  24. <result column="liquidate_date" property="liquidateDate"/>
  25. <result column="performance_start_date" property="performanceStartDate"/>
  26. <result column="is_shareclass" property="isShareclass"/>
  27. <result column="trust_id" property="trustId"/>
  28. <result column="trust_company_name" property="trustCompanyName"/>
  29. <result column="createtime" property="createTime"/>
  30. <result column="updatetime" property="updateTime"/>
  31. <result column="isvalid" property="isvalid"/>
  32. </resultMap>
  33. <select id="searchFundInfoByKeyword" resultType="java.util.Map">
  34. select f.fund_id as "fundId",
  35. f.fund_short_name as "fundShortName",
  36. f.register_number as "registerNumber"
  37. from pvn_fund_info f where f.isvalid =1
  38. <if test="keyword != null and keyword !=''">
  39. and (f.fund_name like concat('%',#{keyword},'%') or f.fund_short_name like concat('%',#{keyword},'%') or f.register_number like concat('%',#{keyword},'%') or f.fund_id like concat('%',#{keyword},'%'))
  40. </if>
  41. limit #{offset},#{pageSize}
  42. </select>
  43. <select id="searchFundInfoList" resultType="com.simuwang.base.pojo.dos.FundInformationDO">
  44. select * from (
  45. select f.id as id,
  46. f.fund_id as fundId,
  47. f.fund_short_name as fundShortName,
  48. f.register_number as registerNumber,
  49. c.company_id as companyId,
  50. c.company_short_name as companyShortName,
  51. c.company_name as companyName,
  52. c.credit_code as creditCode,
  53. f.inception_date as inceptionDate,
  54. n.last_price_date as lastPriceDate,
  55. fn.first_price_date as firstPriceDate,
  56. r.nav_frequency as navFrequency,
  57. r.asset_Frequency as assetFrequency,
  58. r.valuation_Frequency as valuationFrequency,
  59. r.frequency_remark as frequencyRemark
  60. from pvn_fund_info f
  61. left join pvn_company_info c on f.trust_id = c.company_id and c.isvalid =1
  62. left join (select nv.fund_id,max(nv.price_date) as last_price_date from nav nv where nv.isvalid =1 group by nv.fund_id) n
  63. on f.fund_id = n .fund_id
  64. left join (select fnv.fund_id,min(fnv.price_date) as first_price_date from nav fnv where fnv.isvalid =1 group by fnv.fund_id) fn
  65. on f.fund_id = fn .fund_id
  66. left join fund_report_frequency r on r.fund_id = f.fund_id and r.isvalid =1
  67. where f.isvalid =1
  68. <if test="fundId != null and fundId !=''">
  69. and f.fund_id like concat('%',#{fundId},'%')
  70. </if>
  71. <if test="fundShortName != null and fundShortName !=''">
  72. and (f.fund_name like concat('%',#{fundShortName},'%') or f.fund_short_name like concat('%',#{fundShortName},'%') or f.register_number like concat('%',#{fundShortName},'%'))
  73. </if>
  74. <if test="companyShortName != null and companyShortName !=''">
  75. and (c.company_name like concat('%',#{companyShortName},'%') or c.company_short_name like concat('%',#{companyShortName},'%') or c.register_number like concat('%',#{companyShortName},'%'))
  76. </if>
  77. <if test="navFrequency != null and navFrequency !=''">
  78. and r.nav_frequency = #{navFrequency}
  79. </if>
  80. <if test="assetFrequency != null and assetFrequency !=''">
  81. and r.asset_Frequency = #{assetFrequency}
  82. </if>
  83. <if test="valuationFrequency != null and valuationFrequency !=''">
  84. and r.valuation_Frequency = #{valuationFrequency}
  85. </if>
  86. <if test="startDate != null and startDate !=''">
  87. and f.inception_date <![CDATA[ >= ]]> #{startDate}
  88. </if>
  89. <if test="endDate != null and endDate !=''">
  90. and f.inception_date <![CDATA[ <= ]]> #{endDate}
  91. </if>) a
  92. <choose>
  93. <when test="sort != null and sort !='' and sort=='lastPriceDate' and order != null and order !=''">
  94. order by
  95. CASE
  96. WHEN a.lastPriceDate IS NULL THEN 1
  97. ELSE 0
  98. END,
  99. a.lastPriceDate ${order}
  100. </when>
  101. <when test="sort != null and sort !='' and sort=='firstPriceDate' and order != null and order !=''">
  102. order by
  103. CASE
  104. WHEN a.firstPriceDate IS NULL THEN 1
  105. ELSE 0
  106. END,
  107. a.firstPriceDate ${order}
  108. </when>
  109. <otherwise>
  110. order by a.lastPriceDate desc
  111. </otherwise>
  112. </choose>
  113. limit #{offset},#{pageSize}
  114. </select>
  115. <select id="queryFundByNameAndRegisterNumber" resultType="com.simuwang.base.pojo.dos.FundInfoDO">
  116. select fund_id as fundId,
  117. fund_name as fundName,
  118. register_number as registerNumber
  119. from pvn_fund_info
  120. where isvalid = 1
  121. and fund_name = #{fundName}
  122. and register_number = #{registerNumber}
  123. </select>
  124. <select id="queryFundByName" resultType="com.simuwang.base.pojo.dos.FundInfoDO">
  125. select fund_id as fundId,
  126. fund_name as fundName,
  127. register_number as registerNumber
  128. from pvn_fund_info
  129. where isvalid = 1
  130. and fund_name = #{fundName}
  131. </select>
  132. <select id="queryFundByRegisterNumber" resultType="com.simuwang.base.pojo.dos.FundInfoDO">
  133. select fund_id as fundId,
  134. fund_name as fundName,
  135. register_number as registerNumber
  136. from pvn_fund_info
  137. where isvalid = 1
  138. and register_number = #{registerNumber}
  139. </select>
  140. <select id="countFundInfoByKeyword" resultType="java.lang.Long"
  141. parameterType="com.simuwang.base.pojo.dto.query.FundInputPageQuery">
  142. select count(f.fund_id)
  143. from pvn_fund_info f where f.isvalid =1
  144. <if test="keyword != null and keyword !=''">
  145. and (f.fund_name like concat('%',#{keyword},'%') or f.fund_short_name like concat('%',#{keyword},'%') or f.register_number like concat('%',#{keyword},'%') or f.fund_id like concat('%',#{keyword},'%'))
  146. </if>
  147. </select>
  148. <select id="countFundInfo" resultType="java.lang.Long"
  149. parameterType="com.simuwang.base.pojo.dto.query.FundInfoPageQuery">
  150. select count(f.fund_id)
  151. from pvn_fund_info f
  152. left join pvn_company_info c on f.trust_id = c.company_id and c.isvalid =1
  153. left join (select nv.fund_id,max(nv.price_date) as last_price_date from nav nv where nv.isvalid =1 group by nv.fund_id) n
  154. on f.fund_id = n .fund_id
  155. left join (select fnv.fund_id,min(fnv.price_date) as first_price_date from nav fnv where fnv.isvalid =1 group by fnv.fund_id) fn
  156. on f.fund_id = fn .fund_id
  157. left join fund_report_frequency r on r.fund_id = f.fund_id and r.isvalid =1
  158. where f.isvalid =1
  159. <if test="fundId != null and fundId !=''">
  160. and f.fund_id like concat('%',#{fundId},'%')
  161. </if>
  162. <if test="fundShortName != null and fundShortName !=''">
  163. and (f.fund_name like concat('%',#{fundShortName},'%') or f.fund_short_name like concat('%',#{fundShortName},'%') or f.register_number like concat('%',#{fundShortName},'%'))
  164. </if>
  165. <if test="companyShortName != null and companyShortName !=''">
  166. and (c.company_name like concat('%',#{companyShortName},'%') or c.company_short_name like concat('%',#{companyShortName},'%') or c.register_number like concat('%',#{companyShortName},'%'))
  167. </if>
  168. <if test="navFrequency != null and navFrequency !=''">
  169. and r.nav_frequency = #{navFrequency}
  170. </if>
  171. <if test="assetFrequency != null and assetFrequency !=''">
  172. and r.asset_Frequency = #{assetFrequency}
  173. </if>
  174. <if test="valuationFrequency != null and valuationFrequency !=''">
  175. and r.valuation_Frequency = #{valuationFrequency}
  176. </if>
  177. <if test="startDate != null and startDate !=''">
  178. and f.inception_date <![CDATA[ >= ]]> #{startDate}
  179. </if>
  180. <if test="endDate != null and endDate !=''">
  181. and f.inception_date <![CDATA[ <= ]]> #{endDate}
  182. </if>
  183. </select>
  184. <select id="getFundNameByFundId" resultType="java.lang.String" parameterType="java.lang.String">
  185. select fund_name from pvn_fund_info where fund_id=#{fundId} and isvalid=1
  186. </select>
  187. <select id="queryFundIdByName" resultType="java.lang.String" parameterType="java.lang.String">
  188. select fund_id
  189. from pvn_fund_info
  190. where isvalid = 1
  191. and fund_name = #{fundName} limit 1
  192. </select>
  193. <select id="getCompanyNameByFundId" resultType="java.lang.String" parameterType="java.lang.String">
  194. select c.company_name from pvn_company_info c
  195. join pvn_fund_info info on info.trust_id=c.company_id
  196. where info.fund_id=#{fundId} and info.isvalid=1 and c.isvalid=1
  197. </select>
  198. <select id="getLiquidateDateByFundId" resultType="java.lang.String" parameterType="java.lang.String">
  199. select liquidate_date from pvn_fund_info where fund_id=#{fundId} and isvalid=1
  200. </select>
  201. <select id="getFundIdByCompanyId" resultType="java.lang.String" parameterType="java.lang.String">
  202. select info.fund_id from pvn_fund_info info join pvn_company_info c on info.trust_id=c.company_id
  203. where info.isvalid=1 and c.isvalid=1 and c.company_id=#{companyId}
  204. </select>
  205. <select id="getInceptionDateByFundId" resultType="java.lang.String" parameterType="java.lang.String">
  206. select inception_date from pvn_fund_info where fund_id=#{fundId} and isvalid=1
  207. </select>
  208. <select id="queryFundAndTrustByRegisterNumber" resultType="com.simuwang.base.pojo.dos.FundAndCompanyInfoDO">
  209. select t.fund_id as fundId,
  210. t.fund_name as fundName,
  211. t.register_number as registerNumber,
  212. t1.company_id as companyId,
  213. t1.company_name as companyName
  214. from pvn_fund_info t
  215. left join pvn_company_info t1 on t1.isvalid = 1 and t1.company_id = t.trust_id
  216. where t.isvalid = 1
  217. and t.register_number = #{registerNumber}
  218. limit 1
  219. </select>
  220. <select id="searchFundDetail" resultMap="BaseResultMap"
  221. parameterType="java.lang.String">
  222. select info.id,info.p_fund_id,info.fund_id,info.fund_name,
  223. info.fund_short_name,info.fund_type,info.manager_type,
  224. info.base_currency,info.inception_date,info.advisor_id,a.company_name as advisor_company_name,
  225. info.issuer_id,ic.company_name as issuer_company_name,t.company_name as trust_company_name,info.custodian_id,info.trust_id,
  226. info.register_number,info.register_date,info.createtime,
  227. info.is_amac_show,info.fund_status,info.amac_source_type,
  228. info.investment_type,info.liquidate_date,info.performance_start_date,
  229. info.is_shareclass,info.amac_url
  230. from pvn_fund_info info
  231. left join pvn_company_info a
  232. on info.advisor_id = a.company_id and a.isvalid=1
  233. left join pvn_company_info t
  234. on info.trust_id = t.company_id and t.isvalid=1
  235. left join pvn_company_info ic
  236. on info.issuer_id = ic.company_id and ic.isvalid=1
  237. where info.isvalid=1 and info.fund_id=#{fundId}
  238. </select>
  239. <select id="countFundTotal" resultType="java.lang.Long">
  240. select count(1) from pvn_fund_info where isvalid=1
  241. </select>
  242. </mapper>