PublicReleaseCountMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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.goafanti.common.dao.PublicReleaseCountMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.PublicReleaseCount">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="province" jdbcType="INTEGER" property="province" />
  7. <result column="dep_id" jdbcType="VARCHAR" property="depId" />
  8. <result column="uid" jdbcType="VARCHAR" property="uid" />
  9. <result column="quantity" jdbcType="INTEGER" property="quantity" />
  10. <result column="new_user" jdbcType="INTEGER" property="newUser" />
  11. <result column="total" jdbcType="DECIMAL" property="total" />
  12. <result column="date" jdbcType="VARCHAR" property="date" />
  13. <result column="sign" jdbcType="INTEGER" property="sign" />
  14. </resultMap>
  15. <sql id="Base_Column_List">
  16. id, province, dep_id, `uid`, quantity, new_user, total, `date`, sign
  17. </sql>
  18. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  19. select
  20. <include refid="Base_Column_List" />
  21. from public_release_count
  22. where id = #{id,jdbcType=INTEGER}
  23. </select>
  24. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  25. delete from public_release_count
  26. where id = #{id,jdbcType=INTEGER}
  27. </delete>
  28. <insert id="insert" parameterType="com.goafanti.common.model.PublicReleaseCount">
  29. insert into public_release_count (id, province, dep_id,
  30. `uid`, quantity, new_user,
  31. total, `date`, sign)
  32. values (#{id,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{depId,jdbcType=VARCHAR},
  33. #{uid,jdbcType=VARCHAR}, #{quantity,jdbcType=INTEGER}, #{newUser,jdbcType=INTEGER},
  34. #{total,jdbcType=DECIMAL}, #{date,jdbcType=VARCHAR}, #{sign,jdbcType=INTEGER})
  35. </insert>
  36. <insert id="insertSelective" parameterType="com.goafanti.common.model.PublicReleaseCount">
  37. insert into public_release_count
  38. <trim prefix="(" suffix=")" suffixOverrides=",">
  39. <if test="id != null">
  40. id,
  41. </if>
  42. <if test="province != null">
  43. province,
  44. </if>
  45. <if test="depId != null">
  46. dep_id,
  47. </if>
  48. <if test="uid != null">
  49. `uid`,
  50. </if>
  51. <if test="quantity != null">
  52. quantity,
  53. </if>
  54. <if test="newUser != null">
  55. new_user,
  56. </if>
  57. <if test="total != null">
  58. total,
  59. </if>
  60. <if test="date != null">
  61. `date`,
  62. </if>
  63. <if test="sign != null">
  64. sign,
  65. </if>
  66. </trim>
  67. <trim prefix="values (" suffix=")" suffixOverrides=",">
  68. <if test="id != null">
  69. #{id,jdbcType=INTEGER},
  70. </if>
  71. <if test="province != null">
  72. #{province,jdbcType=INTEGER},
  73. </if>
  74. <if test="depId != null">
  75. #{depId,jdbcType=VARCHAR},
  76. </if>
  77. <if test="uid != null">
  78. #{uid,jdbcType=VARCHAR},
  79. </if>
  80. <if test="quantity != null">
  81. #{quantity,jdbcType=INTEGER},
  82. </if>
  83. <if test="newUser != null">
  84. #{newUser,jdbcType=INTEGER},
  85. </if>
  86. <if test="total != null">
  87. #{total,jdbcType=DECIMAL},
  88. </if>
  89. <if test="date != null">
  90. #{date,jdbcType=VARCHAR},
  91. </if>
  92. <if test="sign != null">
  93. #{sign,jdbcType=INTEGER},
  94. </if>
  95. </trim>
  96. </insert>
  97. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PublicReleaseCount">
  98. update public_release_count
  99. <set>
  100. <if test="province != null">
  101. province = #{province,jdbcType=INTEGER},
  102. </if>
  103. <if test="depId != null">
  104. dep_id = #{depId,jdbcType=VARCHAR},
  105. </if>
  106. <if test="uid != null">
  107. `uid` = #{uid,jdbcType=VARCHAR},
  108. </if>
  109. <if test="quantity != null">
  110. quantity = #{quantity,jdbcType=INTEGER},
  111. </if>
  112. <if test="newUser != null">
  113. new_user = #{newUser,jdbcType=INTEGER},
  114. </if>
  115. <if test="total != null">
  116. total = #{total,jdbcType=DECIMAL},
  117. </if>
  118. <if test="date != null">
  119. `date` = #{date,jdbcType=VARCHAR},
  120. </if>
  121. <if test="sign != null">
  122. sign = #{sign,jdbcType=INTEGER},
  123. </if>
  124. </set>
  125. where id = #{id,jdbcType=INTEGER}
  126. </update>
  127. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.PublicReleaseCount">
  128. update public_release_count
  129. set province = #{province,jdbcType=INTEGER},
  130. dep_id = #{depId,jdbcType=VARCHAR},
  131. `uid` = #{uid,jdbcType=VARCHAR},
  132. quantity = #{quantity,jdbcType=INTEGER},
  133. new_user = #{newUser,jdbcType=INTEGER},
  134. total = #{total,jdbcType=DECIMAL},
  135. `date` = #{date,jdbcType=VARCHAR},
  136. sign = #{sign,jdbcType=INTEGER}
  137. where id = #{id,jdbcType=INTEGER}
  138. </update>
  139. <select id="followStatisticsList" resultType="com.goafanti.user.bo.outFollowStatisticsList">
  140. select z.id,z.name,z.use_interview useInterview,z.use_quantity useQuantity,z.use_total useTotal,ifnull(z.useRatio,0)useRatio,
  141. z.new_interview newInterview,z.new_quantity newQuantity,z.new_total newTotal,ifnull(z.newRatio,0)newRatio,
  142. z.totalInterview,z.totalQuantity,z.total,ifnull((z.totalQuantity/z.totalInterview),0)totalRatio
  143. from(select y.id,name,use_interview , use_quantity ,use_total ,(use_quantity/use_interview)useRatio,
  144. new_interview ,new_quantity ,new_total ,(new_quantity/new_interview)newRatio,
  145. (use_interview+new_interview)totalInterview,(use_quantity+new_quantity)totalQuantity,(use_total+new_total)total
  146. from (select dg.id,dg.name,use_interview, use_quantity,use_total,new_interview,new_quantity,new_total
  147. from (select province,sum(if(new_user=1,a.quantity,0))use_interview,sum(if(new_user=1,a.sign ,0))use_quantity,
  148. sum(if(new_user=1,a.total ,0))use_total, sum(if(new_user=0,a.quantity,0))new_interview,sum(if(new_user=0,a.sign ,0))new_quantity,
  149. sum(if(new_user=0,a.total ,0))new_total from public_release_count a
  150. where a.`date` = #{date}
  151. <if test="depId !=null">
  152. and a.dep_id= #{depId}
  153. </if>
  154. <if test="province !=null">
  155. and a.province= #{province}
  156. </if>
  157. group by a.province)x
  158. left join district_glossory dg on x.province=dg.id )y )z
  159. order by
  160. <if test="sort==0">
  161. totalQuantity
  162. </if>
  163. <if test="sort==1">
  164. total
  165. </if>
  166. <if test="sort==2">
  167. totalInterview
  168. </if>
  169. desc
  170. </select>
  171. <select id="provinceFollowStatisticsList" resultType="com.goafanti.user.bo.outProvinceFollowStatistic">
  172. select x.id,x.name,c.id uid,c.nickname ,x.new_user newUser,x.quantity,x.sign
  173. from (select b.id,b.name,a.new_user,a.uid,sum(a.quantity)quantity,sum(a.sign)sign from public_release_count a left join department b on a.dep_id =b.id
  174. where a.date= #{date} and a.province = #{province}
  175. <if test="depId !=null">
  176. and a.dep_id = #{depId}
  177. </if>
  178. <if test="type ==1">
  179. and a.new_user =1
  180. </if>
  181. <if test="type ==2">
  182. and a.new_user =0
  183. </if>
  184. group by b.id,b.name ,a.uid ,a.new_user )x
  185. left join `user` c on x.uid =c.id
  186. order by
  187. <if test="sort==0">
  188. x.sign
  189. </if>
  190. <if test="sort==1">
  191. x.quantity
  192. </if>
  193. desc
  194. </select>
  195. <insert id="insertBatch">
  196. insert into public_release_count (province, dep_id, `uid`,
  197. quantity, new_user, total,
  198. `date`,sign)
  199. values
  200. <foreach collection="list" index="index" item="item" separator=",">
  201. (#{item.province,jdbcType=INTEGER}, #{item.depId,jdbcType=VARCHAR}, #{item.uid,jdbcType=VARCHAR},
  202. #{item.quantity,jdbcType=INTEGER}, #{item.newUser,jdbcType=INTEGER}, #{item.total,jdbcType=DECIMAL},
  203. #{item.date,jdbcType=VARCHAR},#{item.sign,jdbcType=INTEGER})
  204. </foreach>
  205. </insert>
  206. </mapper>