| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydtech.modules.admin.dao.SysGeographyPositionRecordMapper">
- <resultMap type="com.ydtech.modules.admin.model.SysGeographyPositionRecord" id="SysGeographyPositionRecordMap">
- <result property="id" column="id" jdbcType="VARCHAR"/>
- <result property="userId" column="user_id" jdbcType="VARCHAR"/>
- <result property="userName" column="user_name" jdbcType="VARCHAR"/>
- <result property="longitude" column="longitude" jdbcType="VARCHAR"/>
- <result property="latitude" column="latitude" jdbcType="VARCHAR"/>
- <result property="address" column="address" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
- <result property="source" column="source" jdbcType="VARCHAR"/>
- </resultMap>
- <select id="getGeographyPosition" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
- select spa.time ,COUNT(spa.user_id) as countNum
- from(
- SELECT
- DISTINCT s.user_id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
- FROM
- sys_geography_position_record s
- <where>
- <if test="source != null">
- s.source = #{source}
- </if>
- <if test="source == null">
- s.source in (1,2)
- </if>
- <if test="collect !=null and collect.size()>0">
- AND s.user_id in
- <foreach collection="collect" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="queryId != null and queryId != ''">
- and user_id like concat(#{queryId},'%')
- </if>
- <if test="dates != null and dates != ''">
- and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
- </if>
- </where>
- ) as spa
- GROUP BY spa.time
- ORDER BY spa.time ASC
- </select>
- <select id="getGeographyPositionRecord" resultType="com.ydtech.modules.admin.model.SysGeographyPositionRecord">
- SELECT t1.*
- FROM sys_geography_position_record t1
- INNER JOIN (
- SELECT s.user_id, MAX(s.id) AS max_id
- FROM sys_geography_position_record s
- <where>
- <if test="source == null">
- s.source in (1,2)
- </if>
- <if test="source != null">
- s.source = #{source}
- </if>
- <if test="collect !=null and collect.size()>0">
- AND s.user_id in
- <foreach collection="collect" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="queryId != null and queryId != ''">
- and user_id like concat(#{queryId},'%')
- </if>
- <if test="dates != null and dates != ''">
- and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
- </if>
- </where>
- GROUP BY s.user_id
- ) t2 ON t1.id = t2.max_id
- ORDER BY t1.id DESC
- </select>
- <select id="getGeographyPositionSection" resultType="com.ydtech.modules.admin.model.vo.PcAddressHistoryTimeVo">
- select spa.time ,COUNT(spa.user_id) as countNum
- from(
- SELECT
- DISTINCT s.user_id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
- FROM
- sys_geography_position_record s
- <where>
- <if test="source != null">
- s.source = #{source}
- </if>
- <if test="source == null">
- s.source in (1,2)
- </if>
- <if test="collect !=null and collect.size()>0">
- AND s.user_id in
- <foreach collection="collect" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="queryId != null and queryId != ''">
- and user_id like concat(#{queryId},'%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and
- DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
- </if>
- </where>
- ) as spa
- GROUP BY spa.time
- ORDER BY spa.time ASC
- </select>
- <select id="getGeographyPositionHistory" resultType="com.ydtech.modules.admin.model.SysGeographyPositionRecord">
- SELECT t1.*
- FROM sys_geography_position_record t1
- INNER JOIN (
- SELECT s.user_id, MAX(s.id) AS max_id
- FROM sys_geography_position_record s
- <where>
- <if test="source == null">
- s.source in (1,2)
- </if>
- <if test="source != null">
- s.source = #{source}
- </if>
- <if test="collect !=null and collect.size()>0">
- AND s.user_id in
- <foreach collection="collect" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="queryId != null and queryId != ''">
- and user_id like concat(#{queryId},'%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and
- DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
- </if>
- </where>
- GROUP BY s.user_id
- ) t2 ON t1.id = t2.max_id
- ORDER BY t1.id DESC
- </select>
- <select id="queryGeographyHistory" resultType="com.ydtech.modules.admin.model.vo.SysGeographyPositionInfoVo">
- SELECT t1.*
- FROM sys_geography_position_record t1
- INNER JOIN (
- SELECT user_id, MAX(id) AS max_id
- FROM sys_geography_position_record
- <where>
- <if test="dto.lng != null and dto.lng != ''">
- and longitude=#{dto.lng}
- </if>
- <if test="dto.lat != null and dto.lat != ''">
- and latitude=#{dto.lat}
- </if>
- <if test="dto.source != null">
- and source=#{dto.source}
- </if>
- <if test="dto.source == null">
- and source in (1,2)
- </if>
- <if test="dto.queryId != null and dto.queryId != ''">
- and user_id like concat( #{dto.queryId},'%')
- </if>
- <if test="dto.collectIds !=null and dto.collectIds.size()>0">
- and user_id in
- <foreach collection="dto.collectIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="dto.collect !=null and dto.collect.size()>0">
- and user_id in
- <foreach collection="dto.collect" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime != dto.endTime">
- and (DATE_FORMAT(create_time, '%Y-%m-%d' ) between DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ) and
- DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d' ))
- </if>
- <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime == dto.endTime">
- and DATE_FORMAT(create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.startTime}, '%Y-%m-%d' ), '%')
- </if>
- </where>
- GROUP BY user_id) t2 ON t1.id = t2.max_id
- ORDER BY t1.id DESC
- </select>
- </mapper>
|