ContentPlatformDemandVideoMapperExt.xml 13 KB

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