LongArticleBaseMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper">
  4. <delete id="deleteByDateStrGreaterThanEqual">
  5. delete from datastat_sort_strategy where date_str >= #{dateStr}
  6. </delete>
  7. <delete id="deleteByDateStrBetween">
  8. delete from datastat_sort_strategy where date_str between #{dateStrBegin} and #{dateStrEnd} and type = #{type}
  9. </delete>
  10. <select id="countGetOffVideos" resultType="java.lang.Long">
  11. select count(1) from get_off_videos limit #{offset}, #{pageSize}
  12. </select>
  13. <insert id="batchInsertDatastatSortStrategy">
  14. INSERT INTO datastat_sort_strategy
  15. (date_str, publish_time, account_mode, account_source, account_type, account_status, bussiness_type,
  16. account_name, strategy, fans, view_count, avg_view_count, first_view_count, first_avg_view_count,
  17. first_level, fission0, fission1, fission2, second_first_level, second_fission0, second_fission1,
  18. second_fission2, third_first_level, third_fission0, third_fission1, third_fission2,
  19. read_rate, read_fans_rate, first_read_rate, fission0_first_rate, fission1_fission0_rate,
  20. fission0_read_avg_rate, his_read_rate, his_first_read_rate, his_fission0_first_rate, position, gh_id, title,
  21. link, wx_sn, fission0_read_avg_100_rate, fission0_read_avg_500_rate, fission0_read_avg_1000_rate,
  22. crawler_plan_name, crawler_plan_tag, produce_plan_name, produce_plan_tag, publish_plan_name,
  23. publish_mini_program_insert_strategy, publish_mini_program_insert_use_type, publish_mini_program_num,
  24. source_produce_plan_name, account_create_timestamp, publish_timestamp, type)
  25. VALUES
  26. <foreach collection="list" item="item" separator=",">
  27. (#{item.dateStr}, #{item.publishTime}, #{item.accountMode}, #{item.accountSource}, #{item.accountType},
  28. #{item.accountStatus}, #{item.businessType}, #{item.accountName}, #{item.strategy}, #{item.fans},
  29. #{item.viewCount}, #{item.avgViewCount}, #{item.firstViewCount}, #{item.firstAvgViewCount},
  30. #{item.firstLevel}, #{item.fission0}, #{item.fission1}, #{item.fission2}, #{item.secondFirstLevel},
  31. #{item.secondFission0}, #{item.secondFission1}, #{item.secondFission2}, #{item.thirdFirstLevel},
  32. #{item.thirdFission0}, #{item.thirdFission1}, #{item.thirdFission2}, #{item.readRate},
  33. #{item.readFansRate}, #{item.firstReadRate}, #{item.fission0FirstRate}, #{item.fission1Fission0Rate},
  34. #{item.fission0ReadAvgRate}, #{item.hisReadRate}, #{item.hisFirstReadRate}, #{item.hisFission0FirstRate},
  35. #{item.position}, #{item.ghId}, #{item.title}, #{item.link},
  36. #{item.wxSn}, #{item.fission0ReadAvg100Rate}, #{item.fission0ReadAvg500Rate},
  37. #{item.fission0ReadAvg1000Rate}, #{item.crawlerPlanName}, #{item.crawlerPlanTag},
  38. #{item.producePlanName}, #{item.producePlanTag}, #{item.publishPlanName},
  39. #{item.publishMiniProgramInsertStrategy}, #{item.publishMiniProgramInsertUseType},
  40. #{item.publishMiniProgramNum}, #{item.sourceProducePlanName}, #{item.accountCreateTimestamp},
  41. #{item.publishTimestamp}, #{item.type})
  42. </foreach>
  43. </insert>
  44. <insert id="batchInsertArticlePoolPromotionSource">
  45. insert into article_pool_promotion_source
  46. (channel_content_id, source_publish_content_id, root_publish_content_id, root_produce_content_id, title,
  47. title_md5, level, status, deleted, create_timestamp, update_timestamp)
  48. values
  49. <foreach collection="list" item="item" separator=",">
  50. (#{item.channelContentId}, #{item.sourcePublishContentId}, #{item.rootPublishContentId},
  51. #{item.rootProduceContentId}, #{item.title}, #{item.titleMd5}, #{item.level}, #{item.status},
  52. #{item.deleted}, #{item.createTimestamp}, #{item.updateTimestamp})
  53. </foreach>
  54. </insert>
  55. <update id="updateRootProduceContentLevel">
  56. update article_pool_promotion_source set level = #{level} where root_produce_content_id = #{rootProduceContentId}
  57. </update>
  58. <delete id="deleteDatastatScoreByDtIn">
  59. delete from datastat_score where dt in
  60. <foreach collection="dateStrList" item="item" open="(" close=")" separator=",">
  61. #{item}
  62. </foreach>
  63. </delete>
  64. <insert id="batchInsertDatastatScore">
  65. INSERT INTO datastat_score
  66. (dt, gh_id, account_name, `index`, title, strategy, score, similarity, view_count_rate,
  67. his_fission_avg_read_rate_rate, his_fission_avg_read_sum_rate, his_fission_de_weight_avg_read_sum_rate,
  68. read_count, read_avg, read_avg_rate, category, category_score, first_pub_interval, publish_content_id,
  69. crawler_channel_content_id, source_id)
  70. VALUES
  71. <foreach collection="list" item="item" separator=",">
  72. (#{item.dt}, #{item.ghId}, #{item.accountName}, #{item.index}, #{item.title}, #{item.strategy},
  73. #{item.score}, #{item.similarity}, #{item.viewCountRate}, #{item.hisFissionAvgReadRateRate},
  74. #{item.hisFissionAvgReadSumRate}, #{item.hisFissionDeWeightAvgReadSumRate}, #{item.readCount},
  75. #{item.readAvg}, #{item.readAvgRate}, #{item.category}, #{item.categoryScore}, #{item.firstPubInterval},
  76. #{item.publishContentId}, #{item.crawlerChannelContentId}, #{item.sourceId})
  77. </foreach>
  78. </insert>
  79. <insert id="batchInsertArticleCategory">
  80. INSERT INTO article_category
  81. (produce_content_id, channel_content_id, crawler_plan_id, title, title_md5, create_timestamp)
  82. VALUES
  83. <foreach collection="list" item="item" separator=",">
  84. (#{item.produceContentId}, #{item.channelContentId}, #{item.crawlerPlanId}, #{item.title}, #{item.titleMd5},
  85. #{item.createTimestamp})
  86. </foreach>
  87. </insert>
  88. <select id="getArticlePromotion"
  89. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
  90. select *
  91. from datastat_sort_strategy
  92. where view_count >= #{viewCount}
  93. and type = 9
  94. and read_rate >= #{viewCountRate}
  95. and fans > #{fans}
  96. and date_str > #{dateStr}
  97. and position in
  98. <foreach collection="positions" item="item" open="(" close=")" separator=",">
  99. #{item}
  100. </foreach>
  101. </select>
  102. <insert id="batchInsertLongArticlesRootSourceId">
  103. INSERT INTO long_articles_root_source_id (root_source_id, account_name, gh_id, article_title, request_time,
  104. trace_id, push_type, video_id)
  105. VALUES
  106. <foreach collection="list" item="item" index="index" separator=",">
  107. (#{item.rootSourceId}, #{item.accountName}, #{item.ghId}, #{item.articleTitle}, #{item.requestTime},
  108. #{item.traceId}, #{item.pushType}, #{item.videoId})
  109. </foreach>
  110. </insert>
  111. <select id="getGetOffVideos" resultType="com.tzld.longarticle.recommend.server.model.dto.GetOffVideos">
  112. select * from get_off_videos where video_id in
  113. <foreach collection="videoIds" item="item" open="(" close=")" separator=",">
  114. #{item}
  115. </foreach>
  116. </select>
  117. <insert id="batchInsertGetOffVideos">
  118. INSERT INTO get_off_videos (video_id, publish_time, video_status, trace_id, get_off_time, check_status)
  119. VALUES
  120. <foreach collection="list" item="item" separator=",">
  121. (#{item.videoId}, #{item.publishTime}, #{item.videoStatus}, #{item.traceId}, #{item.getOffTime}, #{item.checkStatus})
  122. </foreach>
  123. </insert>
  124. <insert id="batchInsertLongArticlesCrawlerVideos" parameterType="list">
  125. INSERT INTO long_articles_crawler_videos (content_id, out_video_id, platform, video_title, play_count,
  126. like_count, share_count, publish_time, crawler_time, duration,
  127. video_url, cover_url, download_status, video_oss_path, cover_oss_path,
  128. user_id, trace_id, score)
  129. VALUES
  130. <foreach collection="list" item="item" separator=",">
  131. (#{item.contentId}, #{item.outVideoId}, #{item.platform}, #{item.videoTitle}, #{item.playCount},
  132. #{item.likeCount}, #{item.shareCount}, #{item.publishTime}, #{item.crawlerTime}, #{item.duration},
  133. #{item.videoUrl}, #{item.coverUrl}, #{item.downloadStatus}, #{item.videoOssPath}, #{item.coverOssPath},
  134. #{item.userId}, #{item.traceId}, #{item.score})
  135. </foreach>
  136. </insert>
  137. <insert id="batchInsertLongArticlesText" parameterType="list">
  138. INSERT INTO long_articles_text (content_id, article_title, article_text, kimi_title, kimi_summary,
  139. kimi_keys, kimi_status)
  140. VALUES
  141. <foreach collection="list" item="item" separator=",">
  142. (#{item.contentId}, #{item.articleTitle}, #{item.articleText}, #{item.kimiTitle}, #{item.kimiSummary},
  143. #{item.kimiKeys}, #{item.kimiStatus})
  144. </foreach>
  145. </insert>
  146. <select id="getLongArticlesTextByContentIds" resultType="java.lang.String">
  147. select content_id from long_articles_text where content_id in
  148. <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
  149. #{item}
  150. </foreach>
  151. </select>
  152. <select id="getNeedUpdateRecords"
  153. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesText">
  154. select * from long_articles_text where kimi_title is null
  155. </select>
  156. <select id="getLongArticlesRootSourceId"
  157. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticlesRootSourceId">
  158. select * from long_articles_root_source_id where root_source_id in
  159. <foreach collection="rootSourceIdList" item="item" open="(" close=")" separator=",">
  160. #{item}
  161. </foreach>
  162. </select>
  163. <update id="updateLongArticlesText">
  164. update long_articles_text
  165. set kimi_title = #{kimiTitle},
  166. kimi_summary = #{kimiSummary},
  167. kimi_keys = #{kimiKeys}
  168. where content_id = #{contentId}
  169. </update>
  170. <update id="updateLongArticleMatchVideosResponse">
  171. update long_articles_match_videos
  172. set response = #{response}
  173. where trace_id = #{traceId}
  174. </update>
  175. <select id="getLongArticlesMatchVideos"
  176. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesMatchVideos">
  177. select * from long_articles_match_videos where trace_id in
  178. <foreach collection="traceIds" item="item" open="(" close=")" separator=",">
  179. #{item}
  180. </foreach>
  181. </select>
  182. <select id="getLongArticlesCrawlerVideos"
  183. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesCrawlerVideos">
  184. select * from long_articles_crawler_videos where content_id in
  185. <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
  186. #{item}
  187. </foreach>
  188. and download_status = 2
  189. </select>
  190. <select id="getNeedMatchVideos"
  191. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesMatchVideos">
  192. select * from long_articles_match_videos where flow_pool_level is null and id > #{id} order by id limit #{pageSize}
  193. </select>
  194. <select id="countNeedMatchVideos" resultType="java.lang.Integer">
  195. select count(1) from long_articles_match_videos where id > 3962393 and flow_pool_level is null
  196. </select>
  197. <insert id="batchInsertLongArticlesMatchVideos" parameterType="list">
  198. INSERT INTO long_articles_match_videos (trace_id, content_id, flow_pool_level, gh_id, account_name,
  199. content_status, success_status, request_timestamp, response,
  200. process_times)
  201. VALUES
  202. <foreach collection="list" item="item" separator=",">
  203. (#{item.traceId}, #{item.contentId}, #{item.flowPoolLevel}, #{item.ghId}, #{item.accountName},
  204. #{item.contentStatus}, #{item.successStatus}, #{item.requestTimestamp}, #{item.response},
  205. #{item.processTimes})
  206. </foreach>
  207. </insert>
  208. <select id="getPublishSingleVideoSource"
  209. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource">
  210. select content_trace_id, article_title, cover_url, flow_pool_level
  211. from publish_single_video_source
  212. where bad_status = 0 and audit_status = 1
  213. <if test="flowPoolLevel!= null ">
  214. and flow_pool_level = #{flowPoolLevel}
  215. </if>
  216. </select>
  217. <select id="getFilterColdLongArticleTitle" resultType="java.lang.String">
  218. select title from cold_start_title_pool where status in (-1, 1)
  219. </select>
  220. <insert id="batchInsertArticleTitleHisCache">
  221. insert into article_title_his_cache
  222. (source_id, type, title, title_md5, channel_content_id, root_publish_timestamp, crawler_title,
  223. category, his_publish_article_list, create_timestamp)
  224. values
  225. <foreach collection="list" item="item" separator=",">
  226. (#{item.sourceId}, #{item.type}, #{item.title}, #{item.titleMd5}, #{item.channelContentId},
  227. #{item.rootPublishTimestamp}, #{item.crawlerTitle}, #{item.category}, #{item.hisPublishArticleList},
  228. #{item.createTimestamp})
  229. </foreach>
  230. </insert>
  231. </mapper>