FundInfoMapper.xml 14 KB

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