ContentPlatformDemandVideoMapperExt.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformDemandVideoMapperExt">
  4. <insert id="batchInsert" parameterType="java.util.List">
  5. INSERT INTO content_platform_demand_video
  6. (dt, channel_name, crowd_segment, dimension, point_type, standard_element, element_dimension,
  7. category_name, category, demand_id, crowd_package, conversion_target, partner, account, scene_value,
  8. demand_strategy, drive_dimension_time, demand_filter_sort_strategy, demand_type,
  9. demand_content_id, demand_content_title, demand_content_topic, crowd_count, video_count, visit_uv, uv_ratio,
  10. total_rov, online_action, match_experiment_id, match_method, match_video_filter, match_sort,
  11. video_id, config_code, score, sim, rov, match_text, title, cover, video, experiment_id, scene_sum_rov,
  12. channel_level3, status, create_timestamp, update_timestamp,
  13. match_exposure_pv, match_head_single_return_rate, match_head_distribution_single_return_rate)
  14. VALUES
  15. <foreach collection="list" item="item" separator=",">
  16. (#{item.dt}, #{item.channelName}, #{item.crowdSegment}, #{item.dimension}, #{item.pointType},
  17. #{item.standardElement}, #{item.elementDimension}, #{item.categoryName}, #{item.category}, #{item.demandId},
  18. #{item.crowdPackage}, #{item.conversionTarget}, #{item.partner}, #{item.account}, #{item.sceneValue},
  19. #{item.demandStrategy}, #{item.driveDimensionTime}, #{item.demandFilterSortStrategy}, #{item.demandType},
  20. #{item.demandContentId}, #{item.demandContentTitle}, #{item.demandContentTopic},
  21. #{item.crowdCount}, #{item.videoCount}, #{item.visitUv}, #{item.uvRatio}, #{item.totalRov},
  22. #{item.onlineAction}, #{item.matchExperimentId}, #{item.matchMethod}, #{item.matchVideoFilter}, #{item.matchSort},
  23. #{item.videoId}, #{item.configCode}, #{item.score}, #{item.sim}, #{item.rov},
  24. #{item.matchText}, #{item.title}, #{item.cover}, #{item.video}, #{item.experimentId}, #{item.sceneSumRov},
  25. #{item.channelLevel3}, #{item.status}, #{item.createTimestamp}, #{item.updateTimestamp},
  26. #{item.matchExposurePv}, #{item.matchHeadSingleReturnRate}, #{item.matchHeadDistributionSingleReturnRate})
  27. </foreach>
  28. </insert>
  29. <delete id="deleteByDt">
  30. DELETE FROM content_platform_demand_video WHERE dt = #{dt}
  31. </delete>
  32. <delete id="deleteByDtLessThan">
  33. DELETE FROM content_platform_demand_video WHERE dt &lt; #{dt}
  34. </delete>
  35. <delete id="deleteByDtAndChannelName">
  36. DELETE FROM content_platform_demand_video WHERE dt = #{dt} AND channel_name = #{channelName}
  37. </delete>
  38. <select id="selectByCondition" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">
  39. SELECT id, dt, channel_name, channel_level3, crowd_segment, dimension, point_type, standard_element, element_dimension,
  40. category_name, category, demand_id, crowd_package, conversion_target, partner, account, scene_value,
  41. demand_strategy, drive_dimension_time, demand_filter_sort_strategy, demand_type,
  42. demand_content_id, demand_content_title, demand_content_topic,
  43. crowd_count, video_count, visit_uv, uv_ratio, total_rov, online_action, match_experiment_id,
  44. match_method, match_video_filter, match_sort,
  45. video_id, config_code, score, sim, rov,
  46. match_text, title, cover, video, experiment_id, scene_sum_rov, channel_level3, status, create_timestamp, update_timestamp,
  47. match_exposure_pv, match_head_single_return_rate, match_head_distribution_single_return_rate
  48. FROM content_platform_demand_video
  49. WHERE dt = #{dt} AND status = 1
  50. <if test="channelName != null and channelName != ''">
  51. AND channel_name = #{channelName}
  52. </if>
  53. <if test="pointType != null and pointType != ''">
  54. AND point_type = #{pointType}
  55. </if>
  56. <if test="title != null and title != ''">
  57. AND title LIKE CONCAT('%', #{title}, '%')
  58. </if>
  59. <if test="crowdSegment != null and crowdSegment != ''">
  60. AND crowd_segment = #{crowdSegment}
  61. </if>
  62. ORDER BY score DESC
  63. LIMIT #{offset}, #{pageSize}
  64. </select>
  65. <select id="countByCondition" resultType="int">
  66. SELECT COUNT(*) FROM content_platform_demand_video
  67. WHERE dt = #{dt} AND status = 1
  68. <if test="channelName != null and channelName != ''">
  69. AND channel_name = #{channelName}
  70. </if>
  71. <if test="pointType != null and pointType != ''">
  72. AND point_type = #{pointType}
  73. </if>
  74. <if test="title != null and title != ''">
  75. AND title LIKE CONCAT('%', #{title}, '%')
  76. </if>
  77. <if test="crowdSegment != null and crowdSegment != ''">
  78. AND crowd_segment = #{crowdSegment}
  79. </if>
  80. </select>
  81. <select id="getMaxDt" resultType="java.lang.String">
  82. SELECT MAX(dt)
  83. FROM content_platform_demand_video
  84. WHERE status = 1
  85. <if test="channelName != null and channelName != ''">
  86. AND channel_name = #{channelName}
  87. </if>
  88. </select>
  89. <select id="selectChannelNameByGh" resultType="java.lang.String">
  90. SELECT channel_name
  91. FROM content_platform_demand_video
  92. WHERE dt = #{dt}
  93. AND channel_level3 = #{ghName}
  94. AND status = 1
  95. LIMIT 1
  96. </select>
  97. <select id="selectForRecommend" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">
  98. SELECT id, dt, channel_name, channel_level3, crowd_segment, dimension, point_type, standard_element,
  99. category_name, category, demand_id, crowd_package, conversion_target, partner, account, scene_value,
  100. demand_strategy, drive_dimension_time, demand_filter_sort_strategy, demand_type,
  101. demand_content_id, demand_content_title, demand_content_topic,
  102. crowd_count, video_count, visit_uv, uv_ratio, total_rov, online_action, match_experiment_id,
  103. match_method, match_video_filter, match_sort,
  104. video_id, config_code, score, sim, rov,
  105. match_text, title, cover, video, experiment_id, scene_sum_rov, status, create_timestamp, update_timestamp,
  106. match_exposure_pv, match_head_single_return_rate, match_head_distribution_single_return_rate
  107. FROM content_platform_demand_video
  108. WHERE dt = #{dt} AND status = 1
  109. <if test="excludeCategories != null and excludeCategories.size() > 0">
  110. AND (category IS NULL OR category NOT IN
  111. <foreach collection="excludeCategories" item="c" open="(" close=")" separator=",">
  112. #{c}
  113. </foreach>
  114. )
  115. </if>
  116. <if test="channelName != null and channelName != ''">
  117. AND channel_name = #{channelName}
  118. </if>
  119. <if test="crowdSegment != null and crowdSegment != ''">
  120. AND crowd_segment = #{crowdSegment}
  121. </if>
  122. <if test="demandStrategy != null and demandStrategy != ''">
  123. AND demand_strategy = #{demandStrategy}
  124. </if>
  125. <if test="dimension != null and dimension != ''">
  126. AND dimension = #{dimension}
  127. </if>
  128. <if test="dimensionExclude != null and dimensionExclude != ''">
  129. AND (dimension IS NULL OR dimension &lt;&gt; #{dimensionExclude})
  130. </if>
  131. <if test="demandFilterSortStrategyLike != null and demandFilterSortStrategyLike != ''">
  132. AND demand_filter_sort_strategy LIKE #{demandFilterSortStrategyLike}
  133. </if>
  134. <if test="channelLevel3 != null and channelLevel3 != ''">
  135. AND channel_level3 = #{channelLevel3}
  136. </if>
  137. <if test="driveDimensionTime != null and driveDimensionTime != ''">
  138. AND drive_dimension_time = #{driveDimensionTime}
  139. </if>
  140. <if test="category != null and category != ''">
  141. AND category = #{category}
  142. </if>
  143. <if test="matchMethod != null and matchMethod != ''">
  144. AND match_method = #{matchMethod}
  145. </if>
  146. <if test="crowdPackage != null and crowdPackage != ''">
  147. <choose>
  148. <when test='crowdPackage == "泛人群"'>
  149. AND (crowd_segment IS NULL OR crowd_segment = '' OR crowd_segment = '-' OR crowd_segment = 'null')
  150. </when>
  151. <otherwise>
  152. AND crowd_segment = #{crowdPackage}
  153. </otherwise>
  154. </choose>
  155. </if>
  156. <if test="excludeSelfTitle">
  157. AND (title IS NULL OR demand_content_title IS NULL OR title &lt;&gt; demand_content_title)
  158. </if>
  159. ORDER BY total_rov DESC, score DESC
  160. LIMIT #{limit}
  161. </select>
  162. <select id="selectSearchWhitelist" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">
  163. SELECT id, dt, channel_name, channel_level3, crowd_segment, dimension, point_type, standard_element,
  164. category_name, category, demand_id, crowd_package, conversion_target, partner, account, scene_value,
  165. demand_strategy, drive_dimension_time, demand_filter_sort_strategy, demand_type,
  166. demand_content_id, demand_content_title, demand_content_topic,
  167. crowd_count, video_count, visit_uv, uv_ratio, total_rov, online_action, match_experiment_id,
  168. match_method, match_video_filter, match_sort,
  169. video_id, config_code, score, sim, rov,
  170. match_text, title, cover, video, experiment_id, scene_sum_rov, status, create_timestamp, update_timestamp,
  171. match_exposure_pv, match_head_single_return_rate, match_head_distribution_single_return_rate
  172. FROM content_platform_demand_video
  173. WHERE dt = #{dt} AND status = 1
  174. AND channel_name = #{channelName}
  175. AND demand_strategy IN ('人群需求', '优质相似')
  176. AND video_id IS NOT NULL
  177. AND rov IS NOT NULL
  178. AND rov &gt;= 0.03
  179. <if test="crowdSegment != null and crowdSegment != ''">
  180. <choose>
  181. <when test='crowdSegment == "泛人群"'>
  182. AND (crowd_segment IS NULL OR crowd_segment = '' OR crowd_segment = '-' OR crowd_segment = 'null')
  183. </when>
  184. <otherwise>
  185. AND crowd_segment = #{crowdSegment}
  186. </otherwise>
  187. </choose>
  188. </if>
  189. <if test="channelLevel3 != null and channelLevel3 != ''">
  190. AND channel_level3 = #{channelLevel3}
  191. </if>
  192. ORDER BY rov DESC, id ASC
  193. </select>
  194. <select id="selectDistinctCrowdPackages" resultType="java.lang.String">
  195. SELECT DISTINCT
  196. CASE
  197. WHEN crowd_segment IS NULL
  198. OR crowd_segment = ''
  199. OR crowd_segment = '-'
  200. OR crowd_segment = 'null'
  201. THEN '泛人群'
  202. ELSE crowd_segment
  203. END AS cp
  204. FROM content_platform_demand_video
  205. WHERE dt = #{dt} AND status = 1
  206. <if test="channelName != null and channelName != ''">
  207. AND channel_name = #{channelName}
  208. </if>
  209. ORDER BY cp
  210. </select>
  211. <select id="selectActiveVideos" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">
  212. SELECT DISTINCT video_id
  213. FROM content_platform_demand_video
  214. WHERE dt = #{dt} AND status = 1 AND video_id IS NOT NULL
  215. </select>
  216. <update id="updateStatusByVideoId">
  217. UPDATE content_platform_demand_video
  218. SET status = #{status}, update_timestamp = #{updateTimestamp}
  219. WHERE video_id = #{videoId} AND dt = #{dt} AND status = 1
  220. </update>
  221. </mapper>