LongArticleBaseMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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, source_type, source_id)
  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}, #{item.sourceType}, #{item.sourceId})
  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, publish_timestamp)
  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}, #{item.publishTimestamp})
  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, category,
  82. kimi_result, status, create_timestamp)
  83. VALUES
  84. <foreach collection="list" item="item" separator=",">
  85. (#{item.produceContentId}, #{item.channelContentId}, #{item.crawlerPlanId}, #{item.title}, #{item.titleMd5},
  86. #{item.category}, #{item.kimiResult}, #{item.status}, #{item.createTimestamp})
  87. </foreach>
  88. </insert>
  89. <select id="getArticlePromotion"
  90. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
  91. select *
  92. from datastat_sort_strategy
  93. where view_count >= #{viewCount}
  94. and type = 9
  95. and read_rate >= #{viewCountRate}
  96. and fans > #{fans}
  97. and date_str > #{dateStr}
  98. and position in
  99. <foreach collection="positions" item="item" open="(" close=")" separator=",">
  100. #{item}
  101. </foreach>
  102. </select>
  103. <insert id="batchInsertLongArticlesRootSourceId">
  104. INSERT INTO long_articles_root_source_id (root_source_id, account_name, gh_id, article_title, request_time,
  105. trace_id, push_type, video_id)
  106. VALUES
  107. <foreach collection="list" item="item" index="index" separator=",">
  108. (#{item.rootSourceId}, #{item.accountName}, #{item.ghId}, #{item.articleTitle}, #{item.requestTime},
  109. #{item.traceId}, #{item.pushType}, #{item.videoId})
  110. </foreach>
  111. </insert>
  112. <select id="getGetOffVideos" resultType="com.tzld.longarticle.recommend.server.model.dto.GetOffVideos">
  113. select * from get_off_videos where video_id in
  114. <foreach collection="videoIds" item="item" open="(" close=")" separator=",">
  115. #{item}
  116. </foreach>
  117. </select>
  118. <insert id="batchInsertGetOffVideos">
  119. INSERT INTO get_off_videos (video_id, publish_time, video_status, trace_id, get_off_time, check_status)
  120. VALUES
  121. <foreach collection="list" item="item" separator=",">
  122. (#{item.videoId}, #{item.publishTime}, #{item.videoStatus}, #{item.traceId}, #{item.getOffTime}, #{item.checkStatus})
  123. </foreach>
  124. </insert>
  125. <insert id="batchInsertLongArticlesCrawlerVideos" parameterType="list">
  126. INSERT INTO long_articles_crawler_videos (content_id, out_video_id, platform, video_title, play_count,
  127. like_count, share_count, publish_time, crawler_time, duration,
  128. video_url, cover_url, download_status, video_oss_path, cover_oss_path,
  129. user_id, trace_id, score)
  130. VALUES
  131. <foreach collection="list" item="item" separator=",">
  132. (#{item.contentId}, #{item.outVideoId}, #{item.platform}, #{item.videoTitle}, #{item.playCount},
  133. #{item.likeCount}, #{item.shareCount}, #{item.publishTime}, #{item.crawlerTime}, #{item.duration},
  134. #{item.videoUrl}, #{item.coverUrl}, #{item.downloadStatus}, #{item.videoOssPath}, #{item.coverOssPath},
  135. #{item.userId}, #{item.traceId}, #{item.score})
  136. </foreach>
  137. </insert>
  138. <insert id="batchInsertLongArticlesText" parameterType="list">
  139. INSERT INTO long_articles_text (content_id, article_title, article_text, kimi_title, kimi_summary,
  140. kimi_keys, kimi_status)
  141. VALUES
  142. <foreach collection="list" item="item" separator=",">
  143. (#{item.contentId}, #{item.articleTitle}, #{item.articleText}, #{item.kimiTitle}, #{item.kimiSummary},
  144. #{item.kimiKeys}, #{item.kimiStatus})
  145. </foreach>
  146. </insert>
  147. <select id="getLongArticlesTextByContentIds" resultType="java.lang.String">
  148. select content_id from long_articles_text where content_id in
  149. <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
  150. #{item}
  151. </foreach>
  152. </select>
  153. <select id="getNeedUpdateRecords"
  154. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesText">
  155. select * from long_articles_text where kimi_title is null
  156. </select>
  157. <select id="getLongArticlesRootSourceId"
  158. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticlesRootSourceId">
  159. select * from long_articles_root_source_id where root_source_id in
  160. <foreach collection="rootSourceIdList" item="item" open="(" close=")" separator=",">
  161. #{item}
  162. </foreach>
  163. </select>
  164. <update id="updateLongArticlesText">
  165. update long_articles_text
  166. set kimi_title = #{kimiTitle},
  167. kimi_summary = #{kimiSummary},
  168. kimi_keys = #{kimiKeys}
  169. where content_id = #{contentId}
  170. </update>
  171. <update id="updateLongArticleMatchVideosResponse">
  172. update long_articles_match_videos
  173. set response = #{response}
  174. where trace_id = #{traceId}
  175. </update>
  176. <select id="getLongArticlesMatchVideos"
  177. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesMatchVideos">
  178. select * from long_articles_match_videos where trace_id in
  179. <foreach collection="traceIds" item="item" open="(" close=")" separator=",">
  180. #{item}
  181. </foreach>
  182. </select>
  183. <select id="getLongArticlesCrawlerVideos"
  184. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesCrawlerVideos">
  185. select * from long_articles_crawler_videos where content_id in
  186. <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
  187. #{item}
  188. </foreach>
  189. and download_status = 2
  190. </select>
  191. <select id="getNeedMatchVideos"
  192. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesMatchVideos">
  193. select * from long_articles_match_videos where flow_pool_level is null and id > #{id} order by id limit #{pageSize}
  194. </select>
  195. <select id="countNeedMatchVideos" resultType="java.lang.Integer">
  196. select count(1) from long_articles_match_videos where id > 3962393 and flow_pool_level is null
  197. </select>
  198. <insert id="batchInsertLongArticlesMatchVideos" parameterType="list">
  199. INSERT INTO long_articles_match_videos (trace_id, content_id, flow_pool_level, gh_id, account_name,
  200. content_status, success_status, request_timestamp, response,
  201. process_times)
  202. VALUES
  203. <foreach collection="list" item="item" separator=",">
  204. (#{item.traceId}, #{item.contentId}, #{item.flowPoolLevel}, #{item.ghId}, #{item.accountName},
  205. #{item.contentStatus}, #{item.successStatus}, #{item.requestTimestamp}, #{item.response},
  206. #{item.processTimes})
  207. </foreach>
  208. </insert>
  209. <select id="getPublishSingleVideoSource"
  210. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource">
  211. select content_trace_id, article_title, cover_url, flow_pool_level
  212. from publish_single_video_source
  213. where bad_status = 0 and audit_status = 1
  214. <if test="flowPoolLevel!= null ">
  215. and flow_pool_level = #{flowPoolLevel}
  216. </if>
  217. </select>
  218. <select id="getFilterColdLongArticleTitle" resultType="java.lang.String">
  219. select title from cold_start_title_pool where status in (-1, 1)
  220. </select>
  221. <insert id="batchInsertArticleTitleHisCache">
  222. insert into article_title_his_cache
  223. (source_id, type, title, title_md5, channel_content_id, root_publish_timestamp, crawler_title,
  224. category, his_publish_article_list, create_timestamp)
  225. values
  226. <foreach collection="list" item="item" separator=",">
  227. (#{item.sourceId}, #{item.type}, #{item.title}, #{item.titleMd5}, #{item.channelContentId},
  228. #{item.rootPublishTimestamp}, #{item.crawlerTitle}, #{item.category}, #{item.hisPublishArticleList},
  229. #{item.createTimestamp})
  230. </foreach>
  231. </insert>
  232. </mapper>