ContentPlatformDataStatMapperExt.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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.ContentPlatformDataStatMapperExt">
  4. <select id="getGzhAccountDatastatCount" resultType="java.lang.Integer">
  5. select count(1)
  6. from content_platform_gzh_datastat cpgd
  7. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  8. where cpgza.create_account_id = #{createAccountId}
  9. <if test="param.accountId!= null and param.accountId!= ''">
  10. and cpgza.account_id = #{param.accountId}
  11. </if>
  12. </select>
  13. <select id="getGzhAccountDatastatList"
  14. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  15. select cpgd.*
  16. from content_platform_gzh_datastat cpgd
  17. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  18. where cpgza.create_account_id = #{createAccountId}
  19. <if test="param.accountId!= null and param.accountId!= ''">
  20. and cpgza.account_id = #{param.accountId}
  21. </if>
  22. order by cpgd.date_str desc
  23. limit #{offset}, #{pageSize}
  24. </select>
  25. <select id="getGzhTotalDatastatCount" resultType="java.lang.Integer">
  26. select count(1)
  27. from content_platform_gzh_datastat_total cpgdt
  28. join content_platform_account cpa on cpgdt.channel = cpa.channel
  29. where cpa.id = #{createAccountId}
  30. </select>
  31. <select id="getGzhTotalDatastatList"
  32. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  33. select date_str, fans_increase_count, first_level_count, score
  34. from content_platform_gzh_datastat_total cpgdt
  35. join content_platform_account cpa on cpgdt.channel = cpa.channel
  36. where cpa.id = #{createAccountId}
  37. order by cpgdt.date_str desc
  38. limit #{offset}, #{pageSize}
  39. </select>
  40. <select id="getFwhAccountDatastatCount" resultType="java.lang.Integer">
  41. select count(1)
  42. from content_platform_fwh_datastat cpgd
  43. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  44. where cpgza.create_account_id = #{createAccountId}
  45. <if test="param.accountId!= null and param.accountId!= ''">
  46. and cpgza.account_id = #{param.accountId}
  47. </if>
  48. </select>
  49. <select id="getFwhAccountDatastatList"
  50. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  51. select cpfd.*
  52. from content_platform_fwh_datastat cpfd
  53. join content_platform_gzh_account cpgza on cpfd.account_id = cpgza.id
  54. where cpgza.create_account_id = #{createAccountId}
  55. <if test="param.accountId!= null and param.accountId!= ''">
  56. and cpgza.account_id = #{param.accountId}
  57. </if>
  58. order by cpfd.date_str desc
  59. limit #{offset}, #{pageSize}
  60. </select>
  61. <select id="getFwhTotalDatastatCount" resultType="java.lang.Integer">
  62. select count(1)
  63. from content_platform_fwh_datastat_total cpfdt
  64. join content_platform_account cpa on cpfdt.channel = cpa.channel
  65. where cpa.id = #{createAccountId}
  66. </select>
  67. <select id="getFwhTotalDatastatList"
  68. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  69. select date_str, fans_increase_count, first_level_count, score
  70. from content_platform_fwh_datastat_total cpfdt
  71. join content_platform_account cpa on cpfdt.channel = cpa.channel
  72. where cpa.id = #{createAccountId}
  73. order by cpfdt.date_str desc
  74. limit #{offset}, #{pageSize}
  75. </select>
  76. <select id="getQwRootSourceIdDatastatCount" resultType="java.lang.Integer">
  77. select count(1)
  78. from content_platform_qw_datastat cpqd
  79. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  80. where cpqp.create_account_id = #{createAccountId}
  81. </select>
  82. <select id="getQwRootSourceIdDatastatList"
  83. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  84. select cpqd.*
  85. from content_platform_qw_datastat cpqd
  86. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  87. where cpqp.create_account_id = #{createAccountId}
  88. order by cpqd.date_str desc
  89. limit #{offset}, #{pageSize}
  90. </select>
  91. <select id="getQwTotalDatastatCount" resultType="java.lang.Integer">
  92. select count(1)
  93. from content_platform_qw_datastat_total
  94. where channel = #{channel}
  95. </select>
  96. <select id="getQwTotalDatastatList"
  97. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
  98. select date_str, channel, first_level_count, score
  99. from content_platform_qw_datastat_total
  100. where channel = #{channel}
  101. order by date_str desc
  102. limit #{offset}, #{pageSize}
  103. </select>
  104. <select id="getQwReplyTotalDatastatCount" resultType="java.lang.Integer">
  105. select count(1)
  106. from content_platform_qw_datastat_reply_total
  107. where channel = #{channel}
  108. </select>
  109. <select id="getQwReplyTotalDatastatList"
  110. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatReplyTotal">
  111. select date_str, channel, first_level_count, score
  112. from content_platform_qw_datastat_reply_total
  113. where channel = #{channel}
  114. order by date_str desc
  115. limit #{offset}, #{pageSize}
  116. </select>
  117. <select id="getQwSceneDatastatCount" resultType="java.lang.Integer">
  118. select count(1)
  119. from (select cpqd.date_str
  120. from content_platform_qw_datastat cpqd
  121. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  122. where cpqp.create_account_id = #{createAccountId}
  123. and cpqp.scene = #{scene}
  124. group by cpqd.date_str) t
  125. </select>
  126. <select id="getQwSceneDatastatList"
  127. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  128. select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
  129. from content_platform_qw_datastat cpqd
  130. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  131. where cpqp.create_account_id = #{createAccountId}
  132. and cpqp.scene = #{scene}
  133. group by cpqd.date_str
  134. order by cpqd.date_str desc
  135. limit #{offset}, #{pageSize}
  136. </select>
  137. <select id="getQwReplyDatastatCount" resultType="java.lang.Integer">
  138. select count(1)
  139. from (select cpqd.date_str
  140. from content_platform_qw_datastat cpqd
  141. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  142. where cpqp.create_account_id = #{createAccountId}
  143. and cpqp.type = 1
  144. group by cpqd.date_str) t
  145. </select>
  146. <select id="getReplyDatastatList"
  147. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  148. select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
  149. from content_platform_qw_datastat cpqd
  150. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  151. where cpqp.create_account_id = #{createAccountId}
  152. and cpqp.type = 1
  153. group by cpqd.date_str
  154. order by cpqd.date_str desc
  155. limit #{offset}, #{pageSize}
  156. </select>
  157. <insert id="batchInsertGzhDatastat">
  158. insert into content_platform_gzh_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  159. create_timestamp)
  160. values
  161. <foreach collection="records" item="item" separator=",">
  162. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  163. #{item.createTimestamp})
  164. </foreach>
  165. </insert>
  166. <insert id="batchInsertGzhDatastatTotal">
  167. insert into content_platform_gzh_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  168. create_timestamp)
  169. values
  170. <foreach collection="records" item="item" separator=",">
  171. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  172. #{item.createTimestamp})
  173. </foreach>
  174. </insert>
  175. <insert id="batchInsertFwhDatastat">
  176. insert into content_platform_fwh_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  177. create_timestamp)
  178. values
  179. <foreach collection="records" item="item" separator=",">
  180. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  181. #{item.createTimestamp})
  182. </foreach>
  183. </insert>
  184. <insert id="batchInsertFwhDatastatTotal">
  185. insert into content_platform_fwh_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  186. create_timestamp)
  187. values
  188. <foreach collection="records" item="item" separator=",">
  189. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  190. #{item.createTimestamp})
  191. </foreach>
  192. </insert>
  193. <insert id="batchInsertQwDatastat">
  194. insert into content_platform_qw_datastat (date_str, root_source_id, first_level_count, score, create_timestamp)
  195. values
  196. <foreach collection="records" item="item" separator=",">
  197. (#{item.dateStr}, #{item.rootSourceId}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  198. </foreach>
  199. </insert>
  200. <insert id="batchInsertQwDatastatTotal">
  201. insert into content_platform_qw_datastat_total (date_str, channel, first_level_count, score, create_timestamp)
  202. values
  203. <foreach collection="records" item="item" separator=",">
  204. (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  205. </foreach>
  206. </insert>
  207. <insert id="batchInsertQwDatastatReplyTotal">
  208. insert into content_platform_qw_datastat_reply_total (date_str, channel, first_level_count, score, create_timestamp)
  209. values
  210. <foreach collection="records" item="item" separator=",">
  211. (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  212. </foreach>
  213. </insert>
  214. <select id="getQwTotalDatastatScoreList"
  215. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
  216. select cpa.channel, round(avg(cpqd.score), 2) as score
  217. from content_platform_qw_datastat cpqd
  218. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  219. join content_platform_account cpa on cpa.id = cpqp.create_account_id
  220. where cpqd.date_str = #{dt}
  221. group by cpa.channel
  222. </select>
  223. <select id="getQwTotalDatastatReplyScoreList"
  224. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatReplyTotal">
  225. select cpa.channel, round(avg(cpqd.score), 2) as score
  226. from content_platform_qw_datastat cpqd
  227. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  228. join content_platform_account cpa on cpa.id = cpqp.create_account_id
  229. where cpqd.date_str = #{dt} and cpqp.type = 1
  230. group by cpa.channel
  231. </select>
  232. <delete id="deleteQwDatastatTotal">
  233. delete from content_platform_qw_datastat_total where date_str = #{dt}
  234. </delete>
  235. <delete id="deleteQwDatastatReplyTotal">
  236. delete from content_platform_qw_datastat_reply_total where date_str = #{dt}
  237. </delete>
  238. <delete id="deleteGzhDatastatTotal">
  239. delete from content_platform_gzh_datastat_total where date_str = #{dt}
  240. </delete>
  241. <delete id="deleteFwhDatastatTotal">
  242. delete from content_platform_fwh_datastat_total where date_str = #{dt}
  243. </delete>
  244. </mapper>