DeletionInfoMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 PPW_EMAIL.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 PPW_EMAIL.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 PPW_EMAIL.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=sysdate()
  37. </set>
  38. where isvalid = 1 and id=#{itemDo.id}
  39. </foreach>
  40. </update>
  41. <update id="updateRemark">
  42. update PPW_EMAIL.deletion_info set remark=#{remark} where isvalid=1
  43. <if test="fundId != null and fundId !=''">
  44. and fund_id=#{fundId}
  45. </if>
  46. <if test="deletionType != null and deletionType !=''">
  47. and deletion_type=#{deletionType}
  48. </if>
  49. <if test="deletionDate != null and deletionDate !=''">
  50. and deletion_date=#{deletionDate}
  51. </if>
  52. </update>
  53. <select id="searchDeletionList" resultMap="BaseResultMap"
  54. parameterType="com.simuwang.base.pojo.dto.query.DeletionPageQuery">
  55. SELECT
  56. d.fund_id,
  57. info.fund_name,
  58. c.company_name,
  59. d.deletion_type,
  60. ddn.deletion_num,
  61. ddp.processed_num
  62. FROM
  63. PPW_EMAIL.deletion_info d
  64. JOIN PPW_EMAIL.pvn_fund_info info
  65. ON d.fund_id = info.fund_id
  66. JOIN PPW_EMAIL.pvn_company_info c
  67. ON info.trust_id = c.company_id
  68. LEFT JOIN
  69. (SELECT
  70. di.fund_id,
  71. di.deletion_type,
  72. COUNT(di.fund_id) AS deletion_num
  73. FROM
  74. PPW_EMAIL.deletion_info di
  75. WHERE di.isvalid = 1
  76. AND di.remark IS NULL
  77. GROUP BY di.fund_id,
  78. di.deletion_type) ddn
  79. ON ddn.fund_id = d.fund_id
  80. AND d.deletion_type = ddn.deletion_type
  81. LEFT JOIN
  82. (SELECT
  83. dip.fund_id,
  84. dip.deletion_type,
  85. COUNT(dip.fund_id) AS processed_num
  86. FROM
  87. PPW_EMAIL.deletion_info dip
  88. WHERE dip.isvalid = 1
  89. AND dip.remark IS NOT NULL
  90. GROUP BY dip.fund_id,
  91. dip.deletion_type) ddp
  92. ON ddp.fund_id = d.fund_id
  93. AND d.deletion_type = ddp.deletion_type
  94. WHERE d.isvalid = 1
  95. AND info.isvalid = 1
  96. AND c.isvalid = 1
  97. <if test="companyName != null and companyName !=''">
  98. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  99. </if>
  100. <if test="fundName != null and fundName !=''">
  101. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.fund_id like concat('%',#{fundName},'%'))
  102. </if>
  103. <if test="deletionType != null and deletionType != -1">
  104. and d.deletion_type=#{deletionType}
  105. </if>
  106. <if test="deletionStartNum != null and deletionStartNum != ''">
  107. and ddn.deletion_num >= #{deletionStartNum}
  108. </if>
  109. <if test="deletionEndNum != null and deletionEndNum != ''">
  110. and ddn.deletion_num <![CDATA[ <= ]]> #{deletionEndNum}
  111. </if>
  112. group by d.fund_id,d.deletion_type
  113. limit #{offset},#{pageSize}
  114. </select>
  115. <select id="countDeletion" resultType="java.lang.Long"
  116. parameterType="com.simuwang.base.pojo.dto.query.DeletionPageQuery">
  117. select count(1) from (select distinct d.fund_id,d.deletion_type
  118. FROM
  119. PPW_EMAIL.deletion_info d
  120. JOIN PPW_EMAIL.pvn_fund_info info
  121. ON d.fund_id = info.fund_id
  122. JOIN PPW_EMAIL.pvn_company_info c
  123. ON info.trust_id = c.company_id
  124. LEFT JOIN
  125. (SELECT
  126. di.fund_id,
  127. di.deletion_type,
  128. COUNT(di.fund_id) AS deletion_num
  129. FROM
  130. PPW_EMAIL.deletion_info di
  131. WHERE di.isvalid = 1
  132. AND di.remark IS NULL
  133. GROUP BY di.fund_id,
  134. di.deletion_type) ddn
  135. ON ddn.fund_id = d.fund_id
  136. AND d.deletion_type = ddn.deletion_type
  137. LEFT JOIN
  138. (SELECT
  139. dip.fund_id,
  140. dip.deletion_type,
  141. COUNT(dip.fund_id) AS processed_num
  142. FROM
  143. PPW_EMAIL.deletion_info dip
  144. WHERE dip.isvalid = 1
  145. AND dip.remark IS NOT NULL
  146. GROUP BY dip.fund_id,
  147. dip.deletion_type) ddp
  148. ON ddp.fund_id = d.fund_id
  149. AND d.deletion_type = ddp.deletion_type
  150. WHERE d.isvalid = 1
  151. AND info.isvalid = 1
  152. AND c.isvalid = 1
  153. <if test="companyName != null and companyName !=''">
  154. and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%'))
  155. </if>
  156. <if test="fundName != null and fundName !=''">
  157. and (info.fund_name like concat('%',#{fundName},'%') or info.fund_short_name like concat('%',#{fundName},'%') or info.fund_id like concat('%',#{fundName},'%'))
  158. </if>
  159. <if test="deletionType != null and deletionType != -1">
  160. and d.deletion_type=#{deletionType}
  161. </if>
  162. <if test="deletionStartNum != null and deletionStartNum != ''">
  163. and ddn.deletion_num >= #{deletionStartNum}
  164. </if>
  165. <if test="deletionEndNum != null and deletionEndNum != ''">
  166. and ddn.deletion_num <![CDATA[ <= ]]> #{deletionEndNum}
  167. </if>
  168. group by d.fund_id,d.deletion_type) a
  169. </select>
  170. <select id="getLastDeletionDateByFundId" resultType="java.lang.String">
  171. select max(deletion_date) from PPW_EMAIL.deletion_info where fund_id=#{fundId} and deletion_type=#{deletionType}
  172. </select>
  173. <resultMap id="BaseMap" type="com.simuwang.base.pojo.dos.FundDeletionInfoDO">
  174. <id column="id" property="id"/>
  175. <result column="fund_id" property="fundId"/>
  176. <result column="deletion_date" property="deletionDate"/>
  177. <result column="deletion_type" property="deletionType"/>
  178. <result column="remark" property="remark"/>
  179. <result column="isvalid" property="isvalid"/>
  180. <result column="creatorid" property="creatorId"/>
  181. <result column="createtime" property="createTime"/>
  182. <result column="updaterid" property="updaterId"/>
  183. <result column="updatetime" property="updateTime"/>
  184. </resultMap>
  185. <select id="searchFundDeletionList" resultMap="BaseMap"
  186. parameterType="com.simuwang.base.pojo.dto.query.FundDeletionPageQuery">
  187. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime
  188. from PPW_EMAIL.deletion_info where isvalid=1 and fund_id=#{fundId} and remark is null
  189. limit #{offset},#{pageSize}
  190. </select>
  191. <select id="countFundDeletionList" resultType="java.lang.Long"
  192. parameterType="com.simuwang.base.pojo.dto.query.FundDeletionPageQuery">
  193. select count(1)
  194. from PPW_EMAIL.deletion_info where isvalid=1 and fund_id=#{fundId} and remark is null
  195. </select>
  196. <select id="selectFundDeletionInfoVOList" resultType="com.simuwang.base.pojo.dos.FundDeletionInfoDO"
  197. parameterType="java.util.List">
  198. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime
  199. from PPW_EMAIL.deletion_info where isvalid=1 and remark is null
  200. <if test="fundIdList.size() > 0">
  201. and fund_id in
  202. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  203. #{fundId}
  204. </foreach>
  205. </if>
  206. </select>
  207. <select id="getDeletionInfoDO" resultType="com.simuwang.base.pojo.dos.DeletionInfoDO"
  208. parameterType="com.simuwang.base.pojo.dos.DeletionInfoDO">
  209. select id,fund_id,deletion_type,deletion_date,remark,isvalid,creatorid,updaterid,createtime,updatetime
  210. from PPW_EMAIL.deletion_info where isvalid=1
  211. and fund_id=#{fundId} and deletion_date=#{deletionDate} and deletion_type=#{deletionType}
  212. </select>
  213. <resultMap id="BaseEmailMap" type="com.simuwang.base.pojo.dos.EmailDeletionInfoDO">
  214. <result column="fund_name" property="fundName"/>
  215. <result column="company_name" property="companyName"/>
  216. <result column="deletion_date" property="deletionDate"/>
  217. <result column="deletion_type" property="deletionType"/>
  218. </resultMap>
  219. <select id="getDeletionInfoByFundId" resultType="com.simuwang.base.pojo.dos.EmailDeletionInfoDO">
  220. select info.fund_name,c.company_name,d.deletion_type,d.deletion_date
  221. from PPW_EMAIL.deletion_info d
  222. join PPW_EMAIL.pvn_fund_info info on d.fund_id=info.fund_id
  223. join PPW_EMAIL.pvn_company_info c on c.company_id=info.trust_id
  224. where d.isvalid=1 and info.isvalid=1 and c.isvalid=1 and d.remark is null and d.is_send=0
  225. and d.fund_id in
  226. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  227. #{fundId}
  228. </foreach>
  229. order by info.fund_id desc,d.deletion_type desc,d.deletion_date desc
  230. </select>
  231. <update id="removeDistributeDeletion" parameterType="java.lang.String">
  232. update PPW_EMAIL.deletion_info set isvalid=0,updatetime=sysdate() where fund_id=#{fundId} and remark is null
  233. </update>
  234. <update id="updateSendStatusByFundId">
  235. update PPW_EMAIL.deletion_info d set is_send=1,updatetime=sysdate() where isvalid=1
  236. and d.fund_id in
  237. <foreach collection="fundIdList" index="index" item="fundId" separator="," open="(" close=")">
  238. #{fundId}
  239. </foreach>
  240. </update>
  241. </mapper>