LongArticleBaseMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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, fission0_head, fission0_recommend, fission1, fission1_head, fission1_recommend, fission2,
  18. fission2_head, fission2_recommend, second_first_level, second_fission0, second_fission0_head,
  19. second_fission0_recommend, second_fission1, second_fission1_head, second_fission1_recommend,
  20. second_fission2, second_fission2_head, second_fission2_recommend, third_first_level, third_fission0,
  21. third_fission0_head, third_fission0_recommend, third_fission1, third_fission1_head, third_fission1_recommend,
  22. third_fission2,third_fission2_head, third_fission2_recommend,
  23. read_rate, read_fans_rate, first_read_rate, fission0_first_rate, fission0_head_first_rate, fission0_recommend_first_rate, fission1_fission0_rate,
  24. fission0_read_avg_rate, his_read_rate, his_first_read_rate, his_fission0_first_rate, position, gh_id, title,
  25. link, wx_sn, fission0_read_avg_100_rate, fission0_read_avg_500_rate, fission0_read_avg_1000_rate,
  26. crawler_plan_name, crawler_plan_tag, produce_plan_name, produce_plan_tag, publish_plan_name,
  27. publish_mini_program_insert_strategy, publish_mini_program_insert_use_type, publish_mini_program_num,
  28. source_produce_plan_name, account_create_timestamp, publish_timestamp, type, source_type, source_id)
  29. VALUES
  30. <foreach collection="list" item="item" separator=",">
  31. (#{item.dateStr}, #{item.publishTime}, #{item.accountMode}, #{item.accountSource}, #{item.accountType},
  32. #{item.accountStatus}, #{item.businessType}, #{item.accountName}, #{item.strategy}, #{item.fans},
  33. #{item.viewCount}, #{item.avgViewCount}, #{item.firstViewCount}, #{item.firstAvgViewCount},
  34. #{item.firstLevel}, #{item.fission0},#{item.fission0Head},#{item.fission0Recommend}, #{item.fission1},
  35. #{item.fission1Head},#{item.fission1Recommend}, #{item.fission2},#{item.fission2Head},
  36. #{item.fission2Recommend}, #{item.secondFirstLevel}, #{item.secondFission0},
  37. #{item.secondFission0Head}, #{item.secondFission0Recommend}, #{item.secondFission1},
  38. #{item.secondFission1Head}, #{item.secondFission1Recommend}, #{item.secondFission2},
  39. #{item.secondFission2Head}, #{item.secondFission2Recommend}, #{item.thirdFirstLevel},
  40. #{item.thirdFission0}, #{item.thirdFission0Head}, #{item.thirdFission0Recommend},
  41. #{item.thirdFission1}, #{item.thirdFission1Head}, #{item.thirdFission1Recommend},
  42. #{item.thirdFission2}, #{item.thirdFission2Head}, #{item.thirdFission2Recommend}, #{item.readRate},
  43. #{item.readFansRate}, #{item.firstReadRate}, #{item.fission0FirstRate}, #{item.fission0HeadFirstRate},
  44. #{item.fission0RecommendFirstRate}, #{item.fission1Fission0Rate},
  45. #{item.fission0ReadAvgRate}, #{item.hisReadRate}, #{item.hisFirstReadRate}, #{item.hisFission0FirstRate},
  46. #{item.position}, #{item.ghId}, #{item.title}, #{item.link},
  47. #{item.wxSn}, #{item.fission0ReadAvg100Rate}, #{item.fission0ReadAvg500Rate},
  48. #{item.fission0ReadAvg1000Rate}, #{item.crawlerPlanName}, #{item.crawlerPlanTag},
  49. #{item.producePlanName}, #{item.producePlanTag}, #{item.publishPlanName},
  50. #{item.publishMiniProgramInsertStrategy}, #{item.publishMiniProgramInsertUseType},
  51. #{item.publishMiniProgramNum}, #{item.sourceProducePlanName}, #{item.accountCreateTimestamp},
  52. #{item.publishTimestamp}, #{item.type}, #{item.sourceType}, #{item.sourceId})
  53. </foreach>
  54. </insert>
  55. <insert id="batchInsertArticlePoolPromotionSource">
  56. insert into article_pool_promotion_source
  57. (channel_content_id, source_publish_content_id, root_publish_content_id, root_produce_content_id, title,
  58. title_md5, level, status, deleted, create_timestamp, update_timestamp)
  59. values
  60. <foreach collection="list" item="item" separator=",">
  61. (#{item.channelContentId}, #{item.sourcePublishContentId}, #{item.rootPublishContentId},
  62. #{item.rootProduceContentId}, #{item.title}, #{item.titleMd5}, #{item.level}, #{item.status},
  63. #{item.deleted}, #{item.createTimestamp}, #{item.updateTimestamp})
  64. </foreach>
  65. </insert>
  66. <update id="updateRootProduceContentLevel">
  67. update article_pool_promotion_source set level = #{level} where root_produce_content_id = #{rootProduceContentId}
  68. </update>
  69. <delete id="deleteDatastatScoreByDtIn">
  70. delete from datastat_score where dt in
  71. <foreach collection="dateStrList" item="item" open="(" close=")" separator=",">
  72. #{item}
  73. </foreach>
  74. </delete>
  75. <insert id="batchInsertDatastatScore">
  76. INSERT INTO datastat_score
  77. (dt, gh_id, account_name, `index`, title, strategy, score, similarity, view_count_rate,
  78. his_fission_avg_read_rate_rate, his_fission_avg_read_sum_rate, his_fission_de_weight_avg_read_sum_rate,
  79. read_count, read_avg, read_avg_rate, category, category_score, first_pub_interval, publish_content_id,
  80. crawler_channel_content_id, source_id, publish_timestamp)
  81. VALUES
  82. <foreach collection="list" item="item" separator=",">
  83. (#{item.dt}, #{item.ghId}, #{item.accountName}, #{item.index}, #{item.title}, #{item.strategy},
  84. #{item.score}, #{item.similarity}, #{item.viewCountRate}, #{item.hisFissionAvgReadRateRate},
  85. #{item.hisFissionAvgReadSumRate}, #{item.hisFissionDeWeightAvgReadSumRate}, #{item.readCount},
  86. #{item.readAvg}, #{item.readAvgRate}, #{item.category}, #{item.categoryScore}, #{item.firstPubInterval},
  87. #{item.publishContentId}, #{item.crawlerChannelContentId}, #{item.sourceId}, #{item.publishTimestamp})
  88. </foreach>
  89. </insert>
  90. <select id="getArticlePromotion"
  91. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
  92. select *
  93. from datastat_sort_strategy
  94. where view_count >= #{viewCount}
  95. and type = 9
  96. and read_rate >= #{viewCountRate}
  97. and fans > #{fans}
  98. and date_str > #{dateStr}
  99. and position in
  100. <foreach collection="positions" item="item" open="(" close=")" separator=",">
  101. #{item}
  102. </foreach>
  103. </select>
  104. <insert id="batchInsertLongArticlesRootSourceId">
  105. INSERT INTO long_articles_root_source_id (root_source_id, account_name, gh_id, article_title, request_time,
  106. trace_id, push_type, video_id)
  107. VALUES
  108. <foreach collection="list" item="item" index="index" separator=",">
  109. (#{item.rootSourceId}, #{item.accountName}, #{item.ghId}, #{item.articleTitle}, #{item.requestTime},
  110. #{item.traceId}, #{item.pushType}, #{item.videoId})
  111. </foreach>
  112. </insert>
  113. <select id="getGetOffVideos" resultType="com.tzld.longarticle.recommend.server.model.dto.GetOffVideos">
  114. select * from get_off_videos where video_id in
  115. <foreach collection="videoIds" item="item" open="(" close=")" separator=",">
  116. #{item}
  117. </foreach>
  118. </select>
  119. <insert id="batchInsertGetOffVideos">
  120. INSERT INTO get_off_videos (video_id, publish_time, video_status, trace_id, get_off_time, check_status)
  121. VALUES
  122. <foreach collection="list" item="item" separator=",">
  123. (#{item.videoId}, #{item.publishTime}, #{item.videoStatus}, #{item.traceId}, #{item.getOffTime}, #{item.checkStatus})
  124. </foreach>
  125. </insert>
  126. <insert id="batchInsertLongArticlesCrawlerVideos" parameterType="list">
  127. INSERT INTO long_articles_crawler_videos (content_id, out_video_id, platform, video_title, play_count,
  128. like_count, share_count, publish_time, crawler_time, duration,
  129. video_url, cover_url, download_status, video_oss_path, cover_oss_path,
  130. user_id, trace_id, score)
  131. VALUES
  132. <foreach collection="list" item="item" separator=",">
  133. (#{item.contentId}, #{item.outVideoId}, #{item.platform}, #{item.videoTitle}, #{item.playCount},
  134. #{item.likeCount}, #{item.shareCount}, #{item.publishTime}, #{item.crawlerTime}, #{item.duration},
  135. #{item.videoUrl}, #{item.coverUrl}, #{item.downloadStatus}, #{item.videoOssPath}, #{item.coverOssPath},
  136. #{item.userId}, #{item.traceId}, #{item.score})
  137. </foreach>
  138. </insert>
  139. <insert id="batchInsertLongArticlesText" parameterType="list">
  140. INSERT INTO long_articles_text (content_id, article_title, article_text, kimi_title, kimi_summary,
  141. kimi_keys, kimi_status)
  142. VALUES
  143. <foreach collection="list" item="item" separator=",">
  144. (#{item.contentId}, #{item.articleTitle}, #{item.articleText}, #{item.kimiTitle}, #{item.kimiSummary},
  145. #{item.kimiKeys}, #{item.kimiStatus})
  146. </foreach>
  147. </insert>
  148. <select id="getLongArticlesTextByContentIds" resultType="java.lang.String">
  149. select content_id from long_articles_text where content_id in
  150. <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
  151. #{item}
  152. </foreach>
  153. </select>
  154. <select id="getNeedUpdateRecords"
  155. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticlesText">
  156. select * from long_articles_text where kimi_title is null
  157. </select>
  158. <select id="getLongArticlesRootSourceId"
  159. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticlesRootSourceId">
  160. select * from long_articles_root_source_id where root_source_id in
  161. <foreach collection="rootSourceIdList" item="item" open="(" close=")" separator=",">
  162. #{item}
  163. </foreach>
  164. </select>
  165. <update id="updateLongArticlesText">
  166. update long_articles_text
  167. set kimi_title = #{kimiTitle},
  168. kimi_summary = #{kimiSummary},
  169. kimi_keys = #{kimiKeys}
  170. where content_id = #{contentId}
  171. </update>
  172. <update id="updateLongArticleMatchVideosResponse">
  173. update long_articles_match_videos
  174. set response = #{response}
  175. where trace_id = #{traceId}
  176. </update>
  177. <select id="getLongArticlesMatchVideos"
  178. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesMatchVideos">
  179. select * from long_articles_match_videos where trace_id in
  180. <foreach collection="traceIds" item="item" open="(" close=")" separator=",">
  181. #{item}
  182. </foreach>
  183. </select>
  184. <select id="getLongArticlesCrawlerVideos"
  185. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesCrawlerVideos">
  186. select * from long_articles_crawler_videos where content_id in
  187. <foreach collection="contentIds" item="item" open="(" close=")" separator=",">
  188. #{item}
  189. </foreach>
  190. and download_status = 2
  191. </select>
  192. <select id="getNeedMatchVideos"
  193. resultType="com.tzld.longarticle.recommend.server.model.dto.LongArticlesMatchVideos">
  194. select * from long_articles_match_videos where flow_pool_level is null and id > #{id} order by id limit #{pageSize}
  195. </select>
  196. <select id="countNeedMatchVideos" resultType="java.lang.Integer">
  197. select count(1) from long_articles_match_videos where id > 3962393 and flow_pool_level is null
  198. </select>
  199. <insert id="batchInsertLongArticlesMatchVideos" parameterType="list">
  200. INSERT INTO long_articles_match_videos (trace_id, content_id, flow_pool_level, gh_id, account_name,
  201. content_status, success_status, request_timestamp, response,
  202. process_times)
  203. VALUES
  204. <foreach collection="list" item="item" separator=",">
  205. (#{item.traceId}, #{item.contentId}, #{item.flowPoolLevel}, #{item.ghId}, #{item.accountName},
  206. #{item.contentStatus}, #{item.successStatus}, #{item.requestTimestamp}, #{item.response},
  207. #{item.processTimes})
  208. </foreach>
  209. </insert>
  210. <select id="getPublishSingleVideoSource"
  211. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource">
  212. select content_trace_id, article_title, cover_url, flow_pool_level
  213. from publish_single_video_source
  214. where bad_status = 0 and audit_status = 1 and status = 2
  215. <if test="flowPoolLevel!= null ">
  216. and flow_pool_level = #{flowPoolLevel}
  217. </if>
  218. </select>
  219. <select id="getFilterColdLongArticleTitle" resultType="java.lang.String">
  220. select title from cold_start_title_pool where status in (-1, 1)
  221. </select>
  222. <insert id="batchInsertArticleTitleHisCache">
  223. insert into article_title_his_cache
  224. (source_id, type, title, title_md5, kimi_safe_score, channel_content_id, root_publish_timestamp, crawler_title,
  225. category, his_publish_article_list, create_timestamp, plan_id)
  226. values
  227. <foreach collection="list" item="item" separator=",">
  228. (#{item.sourceId}, #{item.type}, #{item.title}, #{item.titleMd5}, #{item.kimiSafeScore},
  229. #{item.channelContentId}, #{item.rootPublishTimestamp}, #{item.crawlerTitle}, #{item.category},
  230. #{item.hisPublishArticleList}, #{item.createTimestamp}, #{item.planId})
  231. </foreach>
  232. </insert>
  233. <select id="getExistsOssPath" resultType="java.lang.String">
  234. select distinct oss_path from long_articles_video_audit where type = #{type}
  235. </select>
  236. <select id="getExistsVideoId" resultType="java.lang.Long">
  237. select video_id from long_articles_video_audit where type = #{type} and create_timestamp > #{todayStart}
  238. </select>
  239. <update id="updateVideoPoolContentBad">
  240. update publish_single_video_source set bad_status = 1 where content_trace_id = #{contentTraceId};
  241. </update>
  242. <insert id="batchInsertArticleReMatchRecord">
  243. insert into article_re_match_record
  244. (trace_id, content_id, oss_path, status, old_response, create_timestamp)
  245. values
  246. <foreach collection="list" item="item" separator=",">
  247. (#{item.traceId}, #{item.contentId}, #{item.ossPath}, #{item.status}, #{item.oldResponse},
  248. #{item.createTimestamp})
  249. </foreach>
  250. </insert>
  251. <select id="getDisAuditDeleteGhid" resultType="java.lang.String">
  252. select distinct gh_id from long_article_audit_delete where create_timestamp > 1736157600000 and status = 2 and fail_reason like 'reach max api daily quota%'
  253. </select>
  254. <select id="countMatchSuccessCount" resultType="java.lang.Long">
  255. select count(content_id)
  256. from long_articles_text
  257. where start_processing_time between #{start} and #{end} and result_status = 1
  258. </select>
  259. <select id="getMatchSuccessContentId" resultType="java.lang.String">
  260. select content_id
  261. from long_articles_text
  262. where start_processing_time between #{start} and #{end} and result_status = 1
  263. </select>
  264. <select id="countMatchCount" resultType="java.lang.Long">
  265. select count(content_id)
  266. from long_articles_text
  267. where start_processing_time between #{start} and #{end}
  268. </select>
  269. <select id="getMatchContentId" resultType="java.lang.String">
  270. select content_id
  271. from long_articles_text
  272. where start_processing_time between #{start} and #{end}
  273. </select>
  274. <select id="getPassContentIds" resultType="java.lang.String">
  275. select content_id from long_articles_title_audit where status = 1 limit 100
  276. </select>
  277. <insert id="batchInsertLongArticleAuditDelete">
  278. insert into long_article_audit_delete
  279. (gh_id, msg_id, `index`, push_id, push_type, publish_content_id, status, delete_reason, create_timestamp)
  280. values
  281. <foreach collection="list" item="item" separator=",">
  282. (#{item.ghId}, #{item.msgId}, #{item.index}, #{item.pushId}, #{item.pushType}, #{item.publishContentId},
  283. #{item.status}, #{item.deleteReason}, #{item.createTimestamp})
  284. </foreach>
  285. </insert>
  286. <select id="getTopContent"
  287. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
  288. select dss.*
  289. from datastat_sort_strategy dss
  290. join (select title, max(read_rate) as read_rate
  291. from datastat_sort_strategy
  292. where date_str &lt; #{dateStr}
  293. and type = 9
  294. and read_rate > 1
  295. and view_count > 10000
  296. and position in (1, 2)
  297. and title not in (select title from article_unsafe_title where status = 1)
  298. and first_level is not null
  299. and strategy is not null
  300. GROUP BY title) top on dss.title = top.title and dss.read_rate = top.read_rate
  301. </select>
  302. <select id="getVideoEndScreenTransformationTask"
  303. resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.VideoEndScreenTransformationTask">
  304. select * from video_end_screen_transformation_task where video_origin_id = #{videoOriginId}
  305. </select>
  306. <insert id="saveVideoEndScreenTransformationTask">
  307. insert into video_end_screen_transformation_task
  308. (video_origin_id, title, oss_path)
  309. values
  310. (#{videoOriginId}, #{title}, #{ossPath})
  311. </insert>
  312. </mapper>