ContentPlatformDataStatMapperExt.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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="getQwSubChannelDatastatCount" resultType="java.lang.Integer">
  118. select count(1)
  119. from content_platform_qw_datastat_sub_channel
  120. where create_account_id = #{channel}
  121. </select>
  122. <select id="getQwSubChannelDatastatList"
  123. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatReplyTotal">
  124. select date_str, sub_channel, first_level_count, score
  125. from content_platform_qw_datastat_sub_channel
  126. where channel = #{channel}
  127. order by date_str desc
  128. limit #{offset}, #{pageSize}
  129. </select>
  130. <select id="getQwSceneDatastatCount" resultType="java.lang.Integer">
  131. select count(1)
  132. from (select cpqd.date_str
  133. from content_platform_qw_datastat cpqd
  134. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  135. where cpqp.create_account_id = #{createAccountId}
  136. and cpqp.scene = #{scene}
  137. group by cpqd.date_str) t
  138. </select>
  139. <select id="getQwSceneDatastatList"
  140. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  141. select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
  142. from content_platform_qw_datastat cpqd
  143. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  144. where cpqp.create_account_id = #{createAccountId}
  145. and cpqp.scene = #{scene}
  146. group by cpqd.date_str
  147. order by cpqd.date_str desc
  148. limit #{offset}, #{pageSize}
  149. </select>
  150. <select id="getQwReplyDatastatCount" resultType="java.lang.Integer">
  151. select count(1)
  152. from (select cpqd.date_str
  153. from content_platform_qw_datastat cpqd
  154. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  155. where cpqp.create_account_id = #{createAccountId}
  156. and cpqp.type = 1
  157. group by cpqd.date_str) t
  158. </select>
  159. <select id="getReplyDatastatList"
  160. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  161. select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
  162. from content_platform_qw_datastat cpqd
  163. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  164. where cpqp.create_account_id = #{createAccountId}
  165. and cpqp.type = 1
  166. group by cpqd.date_str
  167. order by cpqd.date_str desc
  168. limit #{offset}, #{pageSize}
  169. </select>
  170. <insert id="batchInsertGzhDatastat">
  171. insert into content_platform_gzh_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  172. create_timestamp)
  173. values
  174. <foreach collection="records" item="item" separator=",">
  175. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  176. #{item.createTimestamp})
  177. </foreach>
  178. </insert>
  179. <insert id="batchInsertGzhDatastatTotal">
  180. insert into content_platform_gzh_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  181. create_timestamp)
  182. values
  183. <foreach collection="records" item="item" separator=",">
  184. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  185. #{item.createTimestamp})
  186. </foreach>
  187. </insert>
  188. <insert id="batchInsertFwhDatastat">
  189. insert into content_platform_fwh_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  190. create_timestamp)
  191. values
  192. <foreach collection="records" item="item" separator=",">
  193. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  194. #{item.createTimestamp})
  195. </foreach>
  196. </insert>
  197. <insert id="batchInsertFwhDatastatTotal">
  198. insert into content_platform_fwh_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  199. create_timestamp)
  200. values
  201. <foreach collection="records" item="item" separator=",">
  202. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  203. #{item.createTimestamp})
  204. </foreach>
  205. </insert>
  206. <insert id="batchInsertQwDatastat">
  207. insert into content_platform_qw_datastat (date_str, root_source_id, first_level_count, score, create_timestamp)
  208. values
  209. <foreach collection="records" item="item" separator=",">
  210. (#{item.dateStr}, #{item.rootSourceId}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  211. </foreach>
  212. </insert>
  213. <insert id="batchInsertQwDatastatTotal">
  214. insert into content_platform_qw_datastat_total (date_str, channel, first_level_count, score, create_timestamp)
  215. values
  216. <foreach collection="records" item="item" separator=",">
  217. (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  218. </foreach>
  219. </insert>
  220. <insert id="batchInsertQwDatastatReplyTotal">
  221. insert into content_platform_qw_datastat_reply_total (date_str, channel, first_level_count, score, create_timestamp)
  222. values
  223. <foreach collection="records" item="item" separator=",">
  224. (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  225. </foreach>
  226. </insert>
  227. <insert id="batchInsertQwDatastatSubChannel">
  228. insert into content_platform_qw_datastat_sub_channel (date_str, sub_channel, first_level_count, score,
  229. create_account_id, create_timestamp)
  230. values
  231. <foreach collection="records" item="item" separator=",">
  232. (#{item.dateStr}, #{item.subChannel}, #{item.firstLevelCount}, #{item.score}, #{item.createAccountId},
  233. #{item.createTimestamp})
  234. </foreach>
  235. </insert>
  236. <select id="getQwTotalDatastatScoreList"
  237. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
  238. select cpa.channel, round(avg(cpqd.score), 2) as score
  239. from content_platform_qw_datastat cpqd
  240. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  241. join content_platform_account cpa on cpa.id = cpqp.create_account_id
  242. where cpqd.date_str = #{dt}
  243. group by cpa.channel
  244. </select>
  245. <select id="getQwTotalDatastatReplyScoreList"
  246. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatReplyTotal">
  247. select cpa.channel, round(avg(cpqd.score), 2) as score
  248. from content_platform_qw_datastat cpqd
  249. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  250. join content_platform_account cpa on cpa.id = cpqp.create_account_id
  251. where cpqd.date_str = #{dt} and cpqp.type = 1
  252. group by cpa.channel
  253. </select>
  254. <delete id="deleteQwDatastatTotal">
  255. delete from content_platform_qw_datastat_total where date_str = #{dt}
  256. </delete>
  257. <delete id="deleteQwDatastatReplyTotal">
  258. delete from content_platform_qw_datastat_reply_total where date_str = #{dt}
  259. </delete>
  260. <delete id="deleteQwDatastatSubChannel">
  261. delete from content_platform_qw_datastat_sub_channel where date_str = #{dt}
  262. </delete>
  263. <delete id="deleteGzhDatastatTotal">
  264. delete from content_platform_gzh_datastat_total where date_str = #{dt}
  265. </delete>
  266. <delete id="deleteFwhDatastatTotal">
  267. delete from content_platform_fwh_datastat_total where date_str = #{dt}
  268. </delete>
  269. </mapper>