EmailParseInfoMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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.EmailParseInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.EmailParseInfoDO">
  5. <id column="id" property="id"/>
  6. <result column="email" property="email"/>
  7. <result column="sender_email" property="senderEmail"/>
  8. <result column="email_date" property="emailDate" />
  9. <result column="parse_date" property="parseDate" />
  10. <result column="email_title" property="emailTitle"/>
  11. <result column="email_type" property="emailType"/>
  12. <result column="parse_status" property="parseStatus"/>
  13. <result column="fail_reason" property="failReason"/>
  14. <result column="isvalid" property="isvalid"/>
  15. <result column="creatorid" property="creatorId"/>
  16. <result column="createtime" property="createTime"/>
  17. <result column="updaterid" property="updaterId"/>
  18. <result column="updatetime" property="updateTime"/>
  19. <result column="sender_email" property="senderEmail"/>
  20. <result column="review_status" property="reviewStatus"/>
  21. <result column="company_name" property="companyName"/>
  22. </resultMap>
  23. <insert id="insert" parameterType="com.simuwang.base.pojo.dos.EmailParseInfoDO" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  24. insert into email_parse_info(email, sender_email, email_date, parse_date, email_title, email_type, parse_status,
  25. isvalid, creatorid, createtime, updaterid, updatetime,review_status)
  26. values (#{itemDo.email}, #{itemDo.senderEmail}, #{itemDo.emailDate}, #{itemDo.parseDate}, #{itemDo.emailTitle}, #{itemDo.emailType}, #{itemDo.parseStatus},
  27. #{itemDo.isvalid}, #{itemDo.creatorId}, #{itemDo.createTime}, #{itemDo.updaterId}, #{itemDo.updateTime},#{itemDo.reviewStatus})
  28. </insert>
  29. <update id="updateParseStatus">
  30. update email_parse_info
  31. set parse_status = #{parseStatus},
  32. fail_reason = #{failReason},
  33. review_status = #{reviewStatus}
  34. where isvalid = 1
  35. and id = #{id}
  36. </update>
  37. <sql id="selectEmailParse">
  38. SELECT
  39. epi.id,
  40. epi.email,
  41. epi.email_date,
  42. epi.parse_date,
  43. epi.email_title,
  44. epi.email_type,
  45. epi.parse_status,
  46. epi.fail_reason,
  47. epi.isvalid,
  48. epi.creatorid,
  49. epi.createtime,
  50. epi.updatetime,
  51. epi.updaterid,
  52. epi.sender_email,
  53. epi.review_status
  54. FROM
  55. email_parse_info epi
  56. </sql>
  57. <!-- 查询条件 -->
  58. <sql id="sqlwhereSearch">
  59. <where>
  60. epi.isvalid=1
  61. <if test="emailTitle !=null and emailTitle !=''">
  62. and epi.email_title like concat('%',#{emailTitle},'%')
  63. </if>
  64. <if test="emailType !=null">
  65. and epi.email_type = #{emailType}
  66. </if>
  67. <if test="reviewStatus !=null">
  68. and epi.review_status = #{reviewStatus}
  69. </if>
  70. <if test="parseStatus !=null">
  71. and epi.parse_status = #{parseStatus}
  72. </if>
  73. <if test="startDate !=null and startDate != ''">
  74. and epi.parse_date <![CDATA[ >= ]]> #{startDate}
  75. </if>
  76. <if test="endDate !=null and endDate != ''">
  77. and epi.parse_date <![CDATA[ <= ]]> #{endDate}
  78. </if>
  79. <if test="emailStartDate !=null and emailStartDate != ''">
  80. and epi.email_date <![CDATA[ >= ]]> #{emailStartDate}
  81. </if>
  82. <if test="emailEndDate !=null and emailEndDate != ''">
  83. and epi.email_date <![CDATA[ <= ]]> #{emailEndDate}
  84. </if>
  85. <if test="id !=null">
  86. and epi.id = #{id}
  87. </if>
  88. <if test="email !=null and email !=''">
  89. and epi.email like concat('%',#{email},'%')
  90. </if>
  91. <if test="senderEmail !=null and senderEmail !=''">
  92. and epi.sender_email like concat('%',#{senderEmail},'%')
  93. </if>
  94. </where>
  95. </sql>
  96. <select id="searchEmailList" resultMap="BaseResultMap">
  97. SELECT
  98. epi.id,
  99. epi.email,
  100. pci.company_name,
  101. epi.email_date,
  102. epi.parse_date,
  103. epi.email_title,
  104. epi.email_type,
  105. epi.parse_status,
  106. epi.fail_reason,
  107. epi.isvalid,
  108. epi.creatorid,
  109. epi.createtime,
  110. epi.updatetime,
  111. epi.updaterid,
  112. epi.sender_email,
  113. epi.review_status
  114. FROM
  115. email_parse_info epi
  116. left join hosted_email_info hei
  117. on hei.email = epi.sender_email and hei.isvalid=1
  118. left join pvn_company_info pci
  119. on pci.company_id = hei.company_id and pci.isvalid=1
  120. where epi.isvalid=1
  121. <if test="emailTitle !=null and emailTitle !=''">
  122. and epi.email_title like concat('%',#{emailTitle},'%')
  123. </if>
  124. <if test="emailType !=null">
  125. and epi.email_type = #{emailType}
  126. </if>
  127. <if test="reviewStatus !=null">
  128. and epi.review_status = #{reviewStatus}
  129. </if>
  130. <if test="parseStatus !=null">
  131. and epi.parse_status = #{parseStatus}
  132. </if>
  133. <if test="startDate !=null and startDate != ''">
  134. and epi.parse_date <![CDATA[ >= ]]> #{startDate}
  135. </if>
  136. <if test="endDate !=null and endDate != ''">
  137. and epi.parse_date <![CDATA[ <= ]]> #{endDate}
  138. </if>
  139. <if test="emailStartDate !=null and emailStartDate != ''">
  140. and epi.email_date <![CDATA[ >= ]]> #{emailStartDate}
  141. </if>
  142. <if test="emailEndDate !=null and emailEndDate != ''">
  143. and epi.email_date <![CDATA[ <= ]]> #{emailEndDate}
  144. </if>
  145. <if test="id !=null">
  146. and epi.id = #{id}
  147. </if>
  148. <if test="email !=null and email !=''">
  149. and epi.email like concat('%',#{email},'%')
  150. </if>
  151. <if test="senderEmail !=null and senderEmail !=''">
  152. and epi.sender_email like concat('%',#{senderEmail},'%')
  153. </if>
  154. <choose>
  155. <when test="sort != null and sort !='' and sort=='parseDate' and order != null and order !=''">
  156. order by epi.parse_date ${order}
  157. </when>
  158. <when test="sort != null and sort !='' and sort=='emailDate' and order != null and order !=''">
  159. order by epi.email_date ${order}
  160. </when>
  161. <otherwise>
  162. order by epi.parse_date desc
  163. </otherwise>
  164. </choose>
  165. limit #{offset},#{pageSize}
  166. </select>
  167. <select id="searchEmailById" resultMap="BaseResultMap">
  168. <include refid="selectEmailParse"/>
  169. where epi.isvalid =1 and epi.id =#{id}
  170. </select>
  171. <select id="searchEmailCount" resultType="java.lang.Integer">
  172. select count(1) from email_parse_info where isvalid=1
  173. <if test="parseStatus != null and parseStatus != -1">
  174. and parse_status=#{parseStatus}
  175. </if>
  176. <if test="parseStatus != null and parseStatus == -1">
  177. and parse_status != 1
  178. </if>
  179. <if test="startDate != null and startDate != ''">
  180. and parse_date >= #{startDate}
  181. </if>
  182. <if test="endDate != null and endDate != ''">
  183. and parse_date <![CDATA[ <= ]]> #{endDate}
  184. </if>
  185. </select>
  186. <select id="queryById" resultMap="BaseResultMap">
  187. select id, email, email_date, parse_date, email_title, email_type, sender_email,parse_status
  188. from email_parse_info
  189. where isvalid = 1
  190. and id = #{id}
  191. </select>
  192. <select id="countEmailList" resultType="java.lang.Long"
  193. parameterType="com.simuwang.base.pojo.dto.query.EmailParseQuery">
  194. select count(*) from email_parse_info epi
  195. <include refid="sqlwhereSearch"/>
  196. </select>
  197. <update id="updateParseTime">
  198. update email_parse_info
  199. set updatetime = #{parseDate},
  200. parse_date = #{parseDate}
  201. where isvalid = 1
  202. and id = #{id}
  203. </update>
  204. <update id="updateReviewStatus">
  205. update email_parse_info
  206. set updatetime=now(),
  207. review_status = #{reviewStatus},
  208. updaterid=#{userId}
  209. where isvalid = 1
  210. and id in
  211. <foreach item="id" collection="idList" open="(" separator="," close=")">
  212. #{id}
  213. </foreach>
  214. </update>
  215. <select id="queryValuationEmailByFileId" resultType="com.simuwang.base.pojo.dto.EmailInfoDTO">
  216. select t1.id as id,
  217. t1.email as email,
  218. t1.email_date as emailDate,
  219. t1.email_title as emailTitle,
  220. t1.email_type as emailType,
  221. t2.id as fileId,
  222. t2.file_name as fileName,
  223. t2.file_path as filePath
  224. from email_parse_info t1
  225. join email_file_info t2 on t1.id = t2.email_id and t2.isvalid = 1
  226. where t1.isvalid = 1
  227. and t1.email_type = 2
  228. and t2.id in
  229. <foreach collection="fileIdList" item="fileId" index="index" open="(" separator="," close=")">
  230. #{fileId}
  231. </foreach>
  232. </select>
  233. <select id="searchEmailDataBoard" resultType="java.util.Map"
  234. parameterType="com.simuwang.base.pojo.dto.query.DataboardQuery">
  235. select parse_status as "parse_status",count(id) as "total" from email_parse_info
  236. where isvalid=1
  237. <if test="startDate != null and startDate != ''">
  238. and email_date >= #{startDate}
  239. </if>
  240. <if test="endDate != null and endDate != ''">
  241. and email_date <![CDATA[ <= ]]> #{endDate}
  242. </if>
  243. <if test="email !=null and email !=''">
  244. and email like concat('%',#{email},'%')
  245. </if>
  246. <if test="senderEmail !=null and senderEmail !=''">
  247. and sender_email like concat('%',#{senderEmail},'%')
  248. </if>
  249. <if test="emailType !=null">
  250. and email_type = #{emailType}
  251. </if>
  252. group by parse_status
  253. order by parse_status
  254. </select>
  255. <select id="searchEmailTypeCount" resultType="java.util.Map"
  256. parameterType="com.simuwang.base.pojo.dto.query.DataboardQuery">
  257. select email_type as "email_type",count(id) as "total" from email_parse_info
  258. where isvalid=1
  259. <if test="startDate != null and startDate != ''">
  260. and email_date >= #{startDate}
  261. </if>
  262. <if test="endDate != null and endDate != ''">
  263. and email_date <![CDATA[ <= ]]> #{endDate}
  264. </if>
  265. <if test="email !=null and email !=''">
  266. and email like concat('%',#{email},'%')
  267. </if>
  268. <if test="senderEmail !=null and senderEmail !=''">
  269. and sender_email like concat('%',#{senderEmail},'%')
  270. </if>
  271. group by email_type
  272. order by email_type
  273. </select>
  274. <select id="countNoDataByFailReason" resultType="java.lang.Long">
  275. select count(1) from email_parse_info
  276. where isvalid=1
  277. <if test="item.startDate != null and item.startDate != ''">
  278. and email_date >= #{item.startDate}
  279. </if>
  280. <if test="item.endDate != null and item.endDate != ''">
  281. and email_date <![CDATA[ <= ]]> #{item.endDate}
  282. </if>
  283. <if test="item.email !=null and item.email !=''">
  284. and email like concat('%',#{item.email},'%')
  285. </if>
  286. <if test="item.senderEmail !=null and item.senderEmail !=''">
  287. and sender_email like concat('%',#{item.senderEmail},'%')
  288. </if>
  289. <if test="item.emailType !=null">
  290. and email_type = #{item.emailType}
  291. </if>
  292. <if test="errorInfo !=null">
  293. and fail_reason like concat('%',#{errorInfo},'%')
  294. </if>
  295. </select>
  296. <select id="countEmailTotal" resultType="java.lang.Long">
  297. select count(1) from email_parse_info where isvalid=1
  298. <if test="emailType !=null">
  299. and email_type = #{emailType}
  300. </if>
  301. </select>
  302. <select id="queryByEmail" resultMap="BaseResultMap">
  303. select id, email, email_date, parse_date, email_title, email_type, sender_email,parse_status
  304. from email_parse_info
  305. where isvalid = 1
  306. and sender_email = #{senderEmail}
  307. </select>
  308. </mapper>