SysGeographyPositionRecordMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.ydtech.modules.admin.dao.SysGeographyPositionRecordMapper">
  4. <resultMap type="com.ydtech.modules.admin.model.SysGeographyPositionRecord" id="SysGeographyPositionRecordMap">
  5. <result property="id" column="id" jdbcType="VARCHAR"/>
  6. <result property="userId" column="user_id" jdbcType="VARCHAR"/>
  7. <result property="userName" column="user_name" jdbcType="VARCHAR"/>
  8. <result property="longitude" column="longitude" jdbcType="VARCHAR"/>
  9. <result property="latitude" column="latitude" jdbcType="VARCHAR"/>
  10. <result property="address" column="address" jdbcType="VARCHAR"/>
  11. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  12. <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
  13. <result property="source" column="source" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <select id="getGeographyPosition" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
  16. select spa.time ,COUNT(spa.user_id) as countNum
  17. from(
  18. SELECT
  19. DISTINCT s.user_id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
  20. FROM
  21. sys_geography_position_record s
  22. <where>
  23. <if test="source != null">
  24. s.source = #{source}
  25. </if>
  26. <if test="source == null">
  27. s.source in (1,2)
  28. </if>
  29. <if test="collect !=null and collect.size()>0">
  30. AND s.user_id in
  31. <foreach collection="collect" item="item" open="(" close=")" separator=",">
  32. #{item}
  33. </foreach>
  34. </if>
  35. <if test="queryId != null and queryId != ''">
  36. and user_id like concat(#{queryId},'%')
  37. </if>
  38. <if test="dates != null and dates != ''">
  39. and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
  40. </if>
  41. </where>
  42. ) as spa
  43. GROUP BY spa.time
  44. ORDER BY spa.time ASC
  45. </select>
  46. <select id="getGeographyPositionRecord" resultType="com.ydtech.modules.admin.model.SysGeographyPositionRecord">
  47. SELECT t1.*
  48. FROM sys_geography_position_record t1
  49. INNER JOIN (
  50. SELECT s.user_id, MAX(s.id) AS max_id
  51. FROM sys_geography_position_record s
  52. <where>
  53. <if test="source == null">
  54. s.source in (1,2)
  55. </if>
  56. <if test="source != null">
  57. s.source = #{source}
  58. </if>
  59. <if test="collect !=null and collect.size()>0">
  60. AND s.user_id in
  61. <foreach collection="collect" item="item" open="(" close=")" separator=",">
  62. #{item}
  63. </foreach>
  64. </if>
  65. <if test="queryId != null and queryId != ''">
  66. and user_id like concat(#{queryId},'%')
  67. </if>
  68. <if test="dates != null and dates != ''">
  69. and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
  70. </if>
  71. </where>
  72. GROUP BY s.user_id
  73. ) t2 ON t1.id = t2.max_id
  74. ORDER BY t1.id DESC
  75. </select>
  76. <select id="getGeographyPositionSection" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
  77. select spa.time ,COUNT(spa.user_id) as countNum
  78. from(
  79. SELECT
  80. DISTINCT s.user_id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
  81. FROM
  82. sys_geography_position_record s
  83. <where>
  84. <if test="source != null">
  85. s.source = #{source}
  86. </if>
  87. <if test="source == null">
  88. s.source in (1,2)
  89. </if>
  90. <if test="collect !=null and collect.size()>0">
  91. AND s.user_id in
  92. <foreach collection="collect" item="item" open="(" close=")" separator=",">
  93. #{item}
  94. </foreach>
  95. </if>
  96. <if test="queryId != null and queryId != ''">
  97. and user_id like concat(#{queryId},'%')
  98. </if>
  99. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  100. and (DATE_FORMAT(s.create_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and
  101. DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
  102. </if>
  103. </where>
  104. ) as spa
  105. GROUP BY spa.time
  106. ORDER BY spa.time ASC
  107. </select>
  108. <select id="getGeographyPositionHistory" resultType="com.ydtech.modules.admin.model.SysGeographyPositionRecord">
  109. SELECT t1.*
  110. FROM sys_geography_position_record t1
  111. INNER JOIN (
  112. SELECT s.user_id, MAX(s.id) AS max_id
  113. FROM sys_geography_position_record s
  114. <where>
  115. <if test="source == null">
  116. s.source in (1,2)
  117. </if>
  118. <if test="source != null">
  119. s.source = #{source}
  120. </if>
  121. <if test="collect !=null and collect.size()>0">
  122. AND s.user_id in
  123. <foreach collection="collect" item="item" open="(" close=")" separator=",">
  124. #{item}
  125. </foreach>
  126. </if>
  127. <if test="queryId != null and queryId != ''">
  128. and user_id like concat(#{queryId},'%')
  129. </if>
  130. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  131. and (DATE_FORMAT(s.create_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and
  132. DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
  133. </if>
  134. </where>
  135. GROUP BY s.user_id
  136. ) t2 ON t1.id = t2.max_id
  137. ORDER BY t1.id DESC
  138. </select>
  139. <select id="queryGeographyHistory" resultType="com.ydtech.modules.admin.model.vo.SysGeographyPositionInfoVo">
  140. SELECT t1.*
  141. FROM sys_geography_position_record t1
  142. INNER JOIN (
  143. SELECT user_id, MAX(id) AS max_id
  144. FROM sys_geography_position_record
  145. <where>
  146. <if test="dto.lng != null and dto.lng != ''">
  147. and longitude=#{dto.lng}
  148. </if>
  149. <if test="dto.lat != null and dto.lat != ''">
  150. and latitude=#{dto.lat}
  151. </if>
  152. <if test="dto.source != null">
  153. and source=#{dto.source}
  154. </if>
  155. <if test="dto.source == null">
  156. and source in (1,2)
  157. </if>
  158. <if test="dto.queryId != null and dto.queryId != ''">
  159. and user_id like concat( #{dto.queryId},'%')
  160. </if>
  161. <if test="dto.collectIds !=null and dto.collectIds.size()>0">
  162. and user_id in
  163. <foreach collection="dto.collectIds" item="item" open="(" close=")" separator=",">
  164. #{item}
  165. </foreach>
  166. </if>
  167. <if test="dto.collect !=null and dto.collect.size()>0">
  168. and user_id in
  169. <foreach collection="dto.collect" item="item" open="(" close=")" separator=",">
  170. #{item}
  171. </foreach>
  172. </if>
  173. <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime != dto.endTime">
  174. and (DATE_FORMAT(create_time, '%Y-%m-%d' ) between DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ) and
  175. DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d' ))
  176. </if>
  177. <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime == dto.endTime">
  178. and DATE_FORMAT(create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ), '%')
  179. </if>
  180. </where>
  181. GROUP BY user_id) t2 ON t1.id = t2.max_id
  182. ORDER BY t1.id DESC
  183. </select>
  184. </mapper>