EmailFundAssetMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.EmailFundAssetMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.EmailFundAssetDO">
  5. <id column="id" property="id"/>
  6. <result column="file_id" property="fileId"/>
  7. <result column="fund_id" property="fundId"/>
  8. <result column="fund_name" property="fundName"/>
  9. <result column="register_number" property="registerNumber"/>
  10. <result column="price_date" property="priceDate"/>
  11. <result column="asset_net" property="assetNet"/>
  12. <result column="asset_share" property="assetShare"/>
  13. <result column="is_stored" property="isStored"/>
  14. <result column="exception_status" property="exceptionStatus"/>
  15. <result column="isvalid" property="isvalid"/>
  16. <result column="creatorid" property="creatorId"/>
  17. <result column="createtime" property="createTime"/>
  18. <result column="updaterid" property="updaterId"/>
  19. <result column="updatetime" property="updateTime"/>
  20. <result column="email_title" property="emailTitle"/>
  21. <result column="email_id" property="emailId"/>
  22. <result column="target_fund_name" property="targetFundName"/>
  23. <result column="target_fund_id" property="targetFundId"/>
  24. <result column="channel_id" property="channelId"/>
  25. <result column="channel_name" property="channelName"/>
  26. <result column="email" property="email"/>
  27. </resultMap>
  28. <insert id="batchInsert" parameterType="com.simuwang.base.pojo.dos.EmailFundAssetDO">
  29. insert into email_fund_asset(file_id, fund_id, fund_name,register_number,price_date,asset_net,asset_share,is_stored,exception_status,
  30. isvalid, creatorid, createtime, updaterid, updatetime,channel_id)
  31. values
  32. <foreach collection="itemDoList" item="itemDo" index="index" separator=",">
  33. (#{itemDo.fileId},#{itemDo.fundId},#{itemDo.fundName},#{itemDo.registerNumber},#{itemDo.priceDate},#{itemDo.assetNet},#{itemDo.assetShare},#{itemDo.isStored},#{itemDo.exceptionStatus},
  34. #{itemDo.isvalid}, #{itemDo.creatorId}, #{itemDo.createTime}, #{itemDo.updaterId}, #{itemDo.updateTime}, #{itemDo.channelId})
  35. </foreach>
  36. </insert>
  37. <update id="batchUpdate">
  38. <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
  39. update email_fund_asset
  40. <set>
  41. fund_id = #{itemDo.fundId},
  42. exception_status = #{itemDo.exceptionStatus},
  43. updatetime=#{itemDo.updateTime},
  44. is_stored=#{itemDo.isStored}
  45. </set>
  46. where isvalid = 1
  47. and id = #{itemDo.id}
  48. </foreach>
  49. </update>
  50. <select id="searchAssetDetail" resultMap="BaseResultMap"
  51. parameterType="com.simuwang.base.pojo.dto.query.ParseDetailPageQuery">
  52. select asset.id,
  53. asset.fund_id,
  54. asset.fund_name,
  55. asset.register_number,
  56. asset.price_date,
  57. asset.asset_net,
  58. asset.asset_share,
  59. asset.is_stored,
  60. asset.exception_status,
  61. asset.updatetime,
  62. parse.id as email_id,
  63. c.id as channel_id,
  64. c.channel_name as channel_name
  65. from email_fund_asset asset
  66. join email_file_info file
  67. on asset.file_id = file.id
  68. join email_parse_info parse
  69. on file.email_id = parse.id
  70. join channel_info c
  71. on asset.channel_id=c.id and c.isvalid=1
  72. <if test="userId != null and userId !=''">
  73. join user_channel_mapping ucm
  74. on ucm.channel_id = c.id and ucm.isvalid=1
  75. </if>
  76. where asset.isvalid=1 and file.isvalid=1 and parse.isvalid=1
  77. <if test="userId != null and userId !=''">
  78. and ucm.user_id =#{userId}
  79. </if>
  80. <if test="fundName != null and fundName !=''">
  81. and (asset.fund_name like concat(#{fundName},'%'))
  82. </if>
  83. <if test="registerNumber != null and registerNumber !=''">
  84. and (asset.register_number like concat(#{registerNumber},'%'))
  85. </if>
  86. <if test="priceStartDate != null and priceStartDate !=''">
  87. and asset.price_date >= #{priceStartDate}
  88. </if>
  89. <if test="priceEndDate != null and priceEndDate !=''">
  90. and asset.price_date <![CDATA[ <= ]]> #{priceEndDate}
  91. </if>
  92. <if test="updateStartDate != null and updateStartDate !=''">
  93. and asset.updatetime <![CDATA[ >= ]]> #{updateStartDate}
  94. </if>
  95. <if test="updateEndDate != null and updateEndDate !=''">
  96. and asset.updatetime <![CDATA[ <= ]]> #{updateEndDate}
  97. </if>
  98. <if test="isStore != null">
  99. and asset.is_stored = #{isStore}
  100. </if>
  101. <if test="emailId != null and emailId !=''">
  102. and parse.id =#{emailId}
  103. </if>
  104. <if test="email != null and email !=''">
  105. and parse.email like concat('%',#{email},'%')
  106. </if>
  107. <if test="channelName != null and channelName !=''">
  108. and c.channel_name like concat('%',#{channelName},'%')
  109. </if>
  110. <if test="exceptionStatusList != null">
  111. and asset.exception_status in
  112. <foreach collection="exceptionStatusList" index="index" item="exceptionStatus" separator="," open="(" close=")">
  113. #{exceptionStatus}
  114. </foreach>
  115. </if>
  116. <choose>
  117. <when test="sort != null and sort !='' and sort=='priceDate' and order != null and order !=''">
  118. order by asset.price_date ${order}
  119. </when>
  120. <otherwise>
  121. order by asset.price_date desc
  122. </otherwise>
  123. </choose>
  124. limit #{offset},#{pageSize}
  125. </select>
  126. <select id="countAssetDetail" resultType="java.lang.Long"
  127. parameterType="com.simuwang.base.pojo.dto.query.ParseDetailPageQuery">
  128. select count(1) from (
  129. select asset.id,
  130. asset.fund_id,
  131. asset.fund_name,
  132. asset.register_number,
  133. asset.price_date,
  134. asset.asset_net,
  135. asset.asset_share,
  136. asset.is_stored,
  137. asset.exception_status,
  138. asset.updatetime,
  139. parse.id as email_id
  140. from email_fund_asset asset
  141. join email_file_info file
  142. on asset.file_id = file.id
  143. join email_parse_info parse
  144. on file.email_id = parse.id
  145. join channel_info c
  146. on asset.channel_id=c.id and c.isvalid=1
  147. <if test="userId != null and userId !=''">
  148. join user_channel_mapping ucm
  149. on ucm.channel_id = c.id and ucm.isvalid=1
  150. </if>
  151. where asset.isvalid=1 and file.isvalid=1 and parse.isvalid=1
  152. <if test="userId != null and userId !=''">
  153. and ucm.user_id =#{userId}
  154. </if>
  155. <if test="fundName != null and fundName !=''">
  156. and (asset.fund_name like concat('%',#{fundName},'%'))
  157. </if>
  158. <if test="registerNumber != null and registerNumber !=''">
  159. and (asset.register_number like concat(#{registerNumber},'%'))
  160. </if>
  161. <if test="priceStartDate != null and priceStartDate !=''">
  162. and asset.price_date >= #{priceStartDate}
  163. </if>
  164. <if test="priceEndDate != null and priceEndDate !=''">
  165. and asset.price_date <![CDATA[ <= ]]> #{priceEndDate}
  166. </if>
  167. <if test="updateStartDate != null and updateStartDate !=''">
  168. and asset.updatetime <![CDATA[ >= ]]> #{updateStartDate}
  169. </if>
  170. <if test="updateEndDate != null and updateEndDate !=''">
  171. and asset.updatetime <![CDATA[ <= ]]> #{updateEndDate}
  172. </if>
  173. <if test="isStore != null">
  174. and asset.is_stored = #{isStore}
  175. </if>
  176. <if test="emailId != null and emailId !=''">
  177. and parse.id =#{emailId}
  178. </if>
  179. <if test="email != null and email !=''">
  180. and parse.email like concat('%',#{email},'%')
  181. </if>
  182. <if test="channelName != null and channelName !=''">
  183. and c.channel_name like concat('%',#{channelName},'%')
  184. </if>
  185. <if test="exceptionStatusList != null">
  186. and asset.exception_status in
  187. <foreach collection="exceptionStatusList" index="index" item="exceptionStatus" separator="," open="(" close=")">
  188. #{exceptionStatus}
  189. </foreach>
  190. </if>
  191. )a
  192. </select>
  193. <select id="countNoStoreAsset" resultType="java.lang.Integer" parameterType="java.lang.String">
  194. select count(id)
  195. from email_fund_asset
  196. where isvalid =1 and exception_status=3
  197. <if test="fundName != null and fundName !=''">
  198. and fund_name=#{fundName}
  199. </if>
  200. <if test="registerNumber != null and registerNumber !=''">
  201. and register_number=#{registerNumber}
  202. </if>
  203. </select>
  204. <select id="selectNotMappingAsset" resultMap="BaseResultMap"
  205. parameterType="java.lang.String">
  206. select distinct id,fund_id,file_id, fund_name,register_number,price_date,asset_net,asset_share,is_stored,exception_status,
  207. updatetime,channel_id
  208. from email_fund_asset
  209. where isvalid =1 and exception_status=3
  210. <if test="fundName != null and fundName !=''">
  211. and fund_name=#{fundName}
  212. </if>
  213. <if test="registerNumber != null and registerNumber !=''">
  214. and register_number=#{registerNumber}
  215. </if>
  216. </select>
  217. <resultMap id="BaseDetailMap" type="com.simuwang.base.pojo.dos.EmailParseDetailDO">
  218. <result column="fund_id" property="fundId"/>
  219. <result column="fund_name" property="fundName"/>
  220. <result column="register_number" property="registerNumber"/>
  221. <result column="price_date" property="priceDate"/>
  222. <result column="nav" property="nav"/>
  223. <result column="cumulative_nav_withdrawal" property="cumulativeNavWithdrawal"/>
  224. <result column="asset_net" property="assetNet"/>
  225. <result column="asset_share" property="assetShare"/>
  226. <result column="nav_is_stored" property="navIsStored"/>
  227. <result column="nav_exception_status" property="navExceptionStatus"/>
  228. <result column="asset_is_stored" property="assetIsStored"/>
  229. <result column="asset_exception_status" property="assetExceptionStatus"/>
  230. <result column="updatetime" property="updateTime"/>
  231. </resultMap>
  232. <select id="selectFundAssetByFielId" resultMap="BaseDetailMap">
  233. SELECT DISTINCT
  234. asset.fund_id,
  235. asset.fund_name,
  236. asset.register_number,
  237. asset.price_date,
  238. null as nav,
  239. null as cumulative_nav_withdrawal,
  240. asset.asset_net as asset_net,
  241. asset.asset_share as asset_share,
  242. null AS nav_is_stored,
  243. null AS nav_exception_status,
  244. asset.is_stored as asset_is_stored,
  245. asset.exception_status as asset_exception_status,
  246. asset.updatetime
  247. FROM
  248. EMAIL_FILE_INFO efi
  249. JOIN email_fund_asset asset
  250. ON efi.id = asset.file_id
  251. AND asset.isvalid = 1
  252. WHERE efi.isvalid = 1
  253. AND efi.id = #{fileId} and asset.price_date=#{priceDate}
  254. </select>
  255. <select id="selectAssetByFundId" resultMap="BaseResultMap">
  256. select id,file_id, fund_id, fund_name,register_number,price_date,asset_net,asset_share,is_stored,exception_status,
  257. isvalid, creatorid, createtime, updaterid, updatetime,channel_id
  258. from email_fund_asset where isvalid=1 and fund_id=#{fundId}
  259. </select>
  260. <select id="countEmailAssetTotal" resultType="java.lang.Long">
  261. select count(1) from email_fund_asset where isvalid=1
  262. </select>
  263. <delete id="deleteByFileId">
  264. update email_fund_asset
  265. set isvalid = 0,
  266. updatetime= now()
  267. where isvalid = 1
  268. and file_id = #{fileId}
  269. </delete>
  270. </mapper>