DeletionInfoMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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.DeletionInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.DeletionInfoDO">
  5. <id column="id" property="id"/>
  6. <result column="fund_id" property="fundId"/>
  7. <result column="deletion_date" property="deletionDate"/>
  8. <result column="deletion_type" property="deletionType"/>
  9. <result column="company_name" property="companyName"/>
  10. <result column="fund_name" property="fundName"/>
  11. <result column="deletion_num" property="deletionNum"/>
  12. <result column="processed_num" property="processedNum"/>
  13. <result column="isvalid" property="isvalid"/>
  14. <result column="creatorid" property="creatorId"/>
  15. <result column="createtime" property="createTime"/>
  16. <result column="updaterid" property="updaterId"/>
  17. <result column="updatetime" property="updateTime"/>
  18. <result column="is_send" property="isSend"/>
  19. </resultMap>
  20. <insert id="saveDeletionInfoDO" parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
  21. insert into deletion_info(fund_id,deletion_type,deletion_date,isvalid,createtime,updatetime,is_send)
  22. values (#{fundId},#{deletionType},#{deletionDate},#{isvalid},#{createTime},#{updateTime},#{isSend})
  23. </insert>
  24. <update id="update" parameterType="com.simuwang.base.pojo.dos.FundDeletionInfoDO">
  25. update deletion_info set fund_id=#{fundId},deletion_type=#{deletionType},deletion_date=#{deletionDate},remark=#{remark},updatetime=#{updateTime}
  26. where id=#{id} and isvalid=1
  27. </update>
  28. <update id="batchUpdate">
  29. <foreach collection="itemDoList" item="itemDo" index="index" open="" close="" separator=";">
  30. update deletion_info
  31. <set>
  32. fund_id=#{itemDo.fundId},
  33. deletion_type = #{itemDo.deletionType},
  34. deletion_date=#{itemDo.deletionDate},
  35. remark=#{itemDo.remark},
  36. updatetime=now(),
  37. updaterid=#{itemDo.updaterId}
  38. </set>
  39. where isvalid = 1 and id=#{itemDo.id}
  40. </foreach>
  41. </update>
  42. <update id="updateRemark">
  43. update deletion_info set remark=#{remark},updaterid=#{updaterId} where isvalid=1 and remark is null
  44. <if test="fundId != null and fundId !=''">
  45. and fund_id=#{fundId}
  46. </if>
  47. <if test="deletionType != null and deletionType !=''">
  48. and deletion_type=#{deletionType}
  49. </if>
  50. <if test="deletionDate != null and deletionDate !=''">
  51. and deletion_date=#{deletionDate}
  52. </if>
  53. </update>
  54. <delete id="deleteDeletionRemark">
  55. update deletion_info set isvalid=0,updatetime=now() where isvalid=1 and fund_id=#{fundId} and deletion_type=#{deletionType}
  56. <if test="tradeDate != null and tradeDate !=''">
  57. and deletion_date=#{tradeDate}
  58. </if>
  59. </delete>
  60. <delete id="deleteDeletion">
  61. update deletion_info set isvalid=0,updatetime=now() where isvalid=1 and fund_id=#{fundId} and deletion_type=#{deletionType} and remark is null
  62. </delete>
  63. <select id="searchDeletionList" resultMap="BaseResultMap"
  64. parameterType="com.simuwang.base.pojo.dto.query.DeletionPageQuery">
  65. SELECT distinct
  66. d.fund_id,
  67. info.fund_name,
  68. c.company_name,
  69. d.deletion_type,
  70. ddn.deletion_num,
  71. ddp.processed_num
  72. FROM
  73. (SELECT
  74. de.fund_id,
  75. de.deletion_type,
  76. de.isvalid
  77. FROM
  78. deletion_info de
  79. WHERE de.isvalid = 1
  80. GROUP BY de.fund_id,
  81. de.deletion_type,de.isvalid) d
  82. LEFT JOIN pvn_fund_info info
  83. ON d.fund_id = info.fund_id and info.isvalid=1
  84. LEFT JOIN pvn_company_info c
  85. ON info.trust_id = c.company_id and c.isvalid=1
  86. LEFT JOIN
  87. (SELECT
  88. di.fund_id,
  89. di.deletion_type,
  90. COUNT(di.fund_id) AS deletion_num
  91. FROM
  92. deletion_info di
  93. WHERE di.isvalid = 1
  94. AND di.remark IS NULL
  95. GROUP BY di.fund_id,
  96. di.deletion_type) ddn
  97. ON ddn.fund_id = d.fund_id
  98. AND d.deletion_type = ddn.deletion_type
  99. LEFT JOIN
  100. (SELECT
  101. dip.fund_id,
  102. dip.deletion_type,
  103. COUNT(dip.fund_id) AS processed_num
  104. FROM
  105. deletion_info dip
  106. WHERE dip.isvalid = 1
  107. AND dip.remark IS NOT NULL
  108. GROUP BY dip.fund_id,
  109. dip.deletion_type) ddp
  110. ON ddp.fund_id = d.fund_id
  111. AND d.deletion_type = ddp.deletion_type
  112. WHERE d.isvalid = 1
  113. <if test="companyName != null and companyName !=''">
  114. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  115. </if>
  116. <if test="fundName != null and fundName !=''">
  117. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.fund_id like concat('%',#{fundName},'%'))
  118. </if>
  119. <if test="deletionType != null and deletionType != -1">
  120. and d.deletion_type=#{deletionType}
  121. </if>
  122. <if test="deletionStartNum != null and deletionStartNum != ''">
  123. and ddn.deletion_num >= #{deletionStartNum}
  124. </if>
  125. <if test="deletionEndNum != null and deletionEndNum != ''">
  126. and ddn.deletion_num <![CDATA[ <= ]]> #{deletionEndNum}
  127. </if>
  128. limit #{offset},#{pageSize}
  129. </select>
  130. <select id="countDeletion" resultType="java.lang.Long"
  131. parameterType="com.simuwang.base.pojo.dto.query.DeletionPageQuery">
  132. select count(1) from (select distinct
  133. d.fund_id,
  134. info.fund_name,
  135. c.company_name,
  136. d.deletion_type,
  137. ddn.deletion_num,
  138. ddp.processed_num
  139. FROM
  140. deletion_info d
  141. LEFT JOIN pvn_fund_info info
  142. ON d.fund_id = info.fund_id and info.isvalid=1
  143. LEFT JOIN pvn_company_info c
  144. ON info.trust_id = c.company_id and c.isvalid=1
  145. LEFT JOIN
  146. (SELECT
  147. di.fund_id,
  148. di.deletion_type,
  149. COUNT(di.fund_id) AS deletion_num
  150. FROM
  151. deletion_info di
  152. WHERE di.isvalid = 1
  153. AND di.remark IS NULL
  154. GROUP BY di.fund_id,
  155. di.deletion_type) ddn
  156. ON ddn.fund_id = d.fund_id
  157. AND d.deletion_type = ddn.deletion_type
  158. LEFT JOIN
  159. (SELECT
  160. dip.fund_id,
  161. dip.deletion_type,
  162. COUNT(dip.fund_id) AS processed_num
  163. FROM
  164. deletion_info dip
  165. WHERE dip.isvalid = 1
  166. AND dip.remark IS NOT NULL
  167. GROUP BY dip.fund_id,
  168. dip.deletion_type) ddp
  169. ON ddp.fund_id = d.fund_id
  170. AND d.deletion_type = ddp.deletion_type
  171. WHERE d.isvalid = 1
  172. <if test="companyName != null and companyName !=''">
  173. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  174. </if>
  175. <if test="fundName != null and fundName !=''">
  176. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.fund_id like concat('%',#{fundName},'%'))
  177. </if>
  178. <if test="deletionType != null and deletionType != -1">
  179. and d.deletion_type=#{deletionType}
  180. </if>
  181. <if test="deletionStartNum != null and deletionStartNum != ''">
  182. and ddn.deletion_num >= #{deletionStartNum}
  183. </if>
  184. <if test="deletionEndNum != null and deletionEndNum != ''">
  185. and ddn.deletion_num <![CDATA[ <= ]]> #{deletionEndNum}
  186. </if>) a
  187. </select>
  188. <select id="getLastDeletionDateByFundId" resultType="java.lang.String">
  189. select max(deletion_date) from deletion_info where fund_id=#{fundId} and deletion_type=#{deletionType}
  190. </select>
  191. <resultMap id="BaseMap" type="com.simuwang.base.pojo.dos.FundDeletionInfoDO">
  192. <id column="id" property="id"/>
  193. <result column="fund_id" property="fundId"/>
  194. <result column="fund_name" property="fundName"/>
  195. <result column="deletion_date" property="deletionDate"/>
  196. <result column="deletion_type" property="deletionType"/>
  197. <result column="remark" property="remark"/>
  198. <result column="isvalid" property="isvalid"/>
  199. <result column="creatorid" property="creatorId"/>
  200. <result column="createtime" property="createTime"/>
  201. <result column="updaterid" property="updaterId"/>
  202. <result column="updatetime" property="updateTime"/>
  203. </resultMap>
  204. <select id="searchFundDeletionList" resultMap="BaseMap"
  205. parameterType="com.simuwang.base.pojo.dto.query.FundDeletionPageQuery">
  206. SELECT
  207. d.id,
  208. d.fund_id,
  209. info.fund_name,
  210. d.deletion_type,
  211. d.deletion_date,
  212. d.remark,
  213. d.isvalid,
  214. d.creatorid,
  215. d.updaterid,
  216. d.createtime,
  217. d.updatetime
  218. FROM
  219. deletion_info d
  220. left join pvn_fund_info info
  221. on d.fund_id =info.fund_id and info.isvalid=1
  222. WHERE d.isvalid = 1
  223. AND d.fund_id = #{fundId}
  224. AND d.deletion_type = #{deletionType}
  225. ORDER BY deletion_date DESC
  226. limit #{offset},#{pageSize}
  227. </select>
  228. <select id="countFundDeletionList" resultType="java.lang.Long"
  229. parameterType="com.simuwang.base.pojo.dto.query.FundDeletionPageQuery">
  230. select count(d.id)
  231. FROM
  232. deletion_info d
  233. left join pvn_fund_info info
  234. on d.fund_id =info.fund_id and info.isvalid=1
  235. WHERE d.isvalid = 1
  236. AND d.fund_id = #{fundId}
  237. AND d.deletion_type = #{deletionType}
  238. ORDER BY deletion_date DESC
  239. </select>
  240. <select id="selectFundDeletionInfoVOList" resultType="com.simuwang.base.pojo.dos.FundDeletionInfoDO"
  241. parameterType="java.util.List">
  242. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime
  243. from deletion_info where isvalid=1 and remark is null
  244. <if test="fundId != null and fundId !=''">
  245. and fund_id = #{fundId}
  246. </if>
  247. <if test="deletionType != null">
  248. and deletion_type=#{deletionType}
  249. </if>
  250. order by fund_id desc,deletion_type desc ,deletion_date desc
  251. </select>
  252. <select id="getDeletionInfoDO" resultType="com.simuwang.base.pojo.dos.DeletionInfoDO"
  253. parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
  254. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime
  255. from deletion_info where fund_id=#{fundId} and deletion_date=#{deletionDate} and deletion_type=#{deletionType} limit 1
  256. </select>
  257. <resultMap id="BaseEmailMap" type="com.simuwang.base.pojo.dos.EmailDeletionInfoDO">
  258. <result column="fund_name" property="fundName"/>
  259. <result column="company_name" property="companyName"/>
  260. <result column="deletion_date" property="deletionDate"/>
  261. <result column="deletion_type" property="deletionType"/>
  262. </resultMap>
  263. <select id="getDeletionInfoByFundId" resultType="com.simuwang.base.pojo.dos.EmailDeletionInfoDO">
  264. select info.fund_name,c.company_name,d.deletion_type,d.deletion_date
  265. from deletion_info d
  266. join pvn_fund_info info on d.fund_id=info.fund_id
  267. join pvn_company_info c on c.company_id=info.trust_id
  268. where d.isvalid=1 and info.isvalid=1 and c.isvalid=1 and d.remark is null and d.is_send=0
  269. and d.fund_id in
  270. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  271. #{fundId}
  272. </foreach>
  273. order by info.fund_id desc,d.deletion_type desc,d.deletion_date desc
  274. </select>
  275. <update id="removeDistributeDeletion" parameterType="java.lang.String">
  276. update deletion_info set isvalid=0,updatetime=now() where fund_id=#{fundId} and remark is null
  277. </update>
  278. <update id="updateSendStatusByFundId">
  279. update deletion_info d set is_send=1,updatetime=now() where isvalid=1
  280. and d.fund_id in
  281. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  282. #{fundId}
  283. </foreach>
  284. </update>
  285. <update id="updateDeletionInfoDO">
  286. update deletion_info d set isvalid=1,updatetime=now() where id=#{id}
  287. </update>
  288. </mapper>