DeletionInfoMapper.xml 11 KB

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