| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?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.SysPcAddressHistoryMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
- <id property="id" column="id" jdbcType="BIGINT"/>
- <id property="userId" column="user_id" jdbcType="VARCHAR"/>
- <result property="userName" column="user_name" jdbcType="VARCHAR"/>
- <result property="ip" column="ip" 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="operationTime" column="operation_time" jdbcType="TIMESTAMP"/>
- <result property="province" column="prov" jdbcType="VARCHAR"/>
- <result property="city" column="city" jdbcType="VARCHAR"/>
- <result property="district" column="district" jdbcType="VARCHAR"/>
- <result property="source" column="source" jdbcType="VARCHAR"/>
- </resultMap>
- <select id="getPcAddress" 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.operation_time, '%Y-%m-%d %H' ) as time
- FROM
- sys_pc_address_history 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="dates != null and dates != ''">
- and DATE_FORMAT(s.operation_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="getPcAddressSection" 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.operation_time, '%Y-%m-%d' ) as time
- FROM
- sys_pc_address_history 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="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and (DATE_FORMAT(s.operation_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="getPcAddressHistory" resultType="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
- SELECT t1.*
- FROM sys_pc_address_history t1
- INNER JOIN (
- SELECT s.user_id, MAX(s.id) AS max_id
- FROM sys_pc_address_history 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="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and (DATE_FORMAT(s.operation_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="getPcAddressInfo" resultType="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
- SELECT t1.*
- FROM sys_pc_address_history t1
- INNER JOIN (
- SELECT s.user_id, MAX(s.id) AS max_id
- FROM sys_pc_address_history 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="dates != null and dates != ''">
- and DATE_FORMAT(s.operation_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="queryAddressHistory" resultType="com.ydtech.modules.admin.model.po.SysPcAddressHistory">
- SELECT t1.*
- FROM sys_pc_address_history t1
- INNER JOIN (
- SELECT user_id, MAX(id) AS max_id
- FROM sys_pc_address_history
- <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.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.queryId != null and dto.queryId != ''">
- and user_id like concat(#{dto.queryId},'%')
- </if>
- <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''and dto.startTime != dto.endTime">
- and (DATE_FORMAT(operation_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(operation_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>
|