<?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.ruoyi.interfaces.mapper.PtStatMapper">
    <resultMap id="BaseResultMap" type="com.ruoyi.interfaces.domain.PtStat">
        <id column="ID" jdbcType="VARCHAR" property="id"/>
        <result column="BROWSER" jdbcType="VARCHAR" property="browser"/>
        <result column="OS" jdbcType="VARCHAR" property="os"/>
        <result column="SCREEN" jdbcType="VARCHAR" property="screen"/>
        <result column="COLOR" jdbcType="VARCHAR" property="color"/>
        <result column="COOKIE" jdbcType="VARCHAR" property="cookie"/>
        <result column="LANG" jdbcType="VARCHAR" property="lang"/>
        <result column="CHARSET" jdbcType="VARCHAR" property="charset"/>
        <result column="APPID" jdbcType="VARCHAR" property="appid"/>
        <result column="TITLE" jdbcType="VARCHAR" property="title"/>
        <result column="URL" jdbcType="VARCHAR" property="url"/>
        <result column="HOST" jdbcType="VARCHAR" property="host"/>
        <result column="IP" jdbcType="VARCHAR" property="ip"/>
        <result column="TM" jdbcType="TIMESTAMP" property="tm"/>
        <result column="VISTOR" jdbcType="VARCHAR" property="vistor"/>
        <result column="STICKTIME" jdbcType="DECIMAL" property="sticktime"/>
        <result column="NUM" jdbcType="VARCHAR" property="num"/>
        <result column="DAY" jdbcType="VARCHAR" property="day"/>
        <result column="CNT" jdbcType="VARCHAR" property="cnt"/>
    </resultMap>
    <sql id="Base_Column_List">
        ID
        , BROWSER, OS, SCREEN, COLOR, COOKIE, LANG, CHARSET, APPID, TITLE, URL, HOST, IP,
    TM, VISTOR, STICKTIME
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from PT_STAT
        where ID = #{id,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete
        from PT_STAT
        where ID = #{id,jdbcType=VARCHAR}
    </delete>
    <insert id="insert" parameterType="com.ruoyi.interfaces.domain.PtStat">
        insert into PT_STAT (ID, BROWSER, OS,
                             SCREEN, COLOR, COOKIE,
                             LANG, CHARSET, APPID,
                             TITLE, URL, HOST, IP,
                             TM, VISTOR, STICKTIME)
        values (#{id,jdbcType=VARCHAR}, #{browser,jdbcType=VARCHAR}, #{os,jdbcType=VARCHAR},
                #{screen,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR}, #{cookie,jdbcType=VARCHAR},
                #{lang,jdbcType=VARCHAR}, #{charset,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR},
                #{title,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{host,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
                #{tm,jdbcType=TIMESTAMP}, #{vistor,jdbcType=VARCHAR}, #{sticktime,jdbcType=DECIMAL})
    </insert>
    <insert id="insertSelective" parameterType="com.ruoyi.interfaces.domain.PtStat">
        insert into PT_STAT
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                ID,
            </if>
            <if test="browser != null">
                BROWSER,
            </if>
            <if test="os != null">
                OS,
            </if>
            <if test="screen != null">
                SCREEN,
            </if>
            <if test="color != null">
                COLOR,
            </if>
            <if test="cookie != null">
                COOKIE,
            </if>
            <if test="lang != null">
                LANG,
            </if>
            <if test="charset != null">
                CHARSET,
            </if>
            <if test="appid != null">
                APPID,
            </if>
            <if test="title != null">
                TITLE,
            </if>
            <if test="url != null">
                URL,
            </if>
            <if test="host != null">
                HOST,
            </if>
            <if test="ip != null">
                IP,
            </if>
            <if test="tm != null">
                TM,
            </if>
            <if test="vistor != null">
                VISTOR,
            </if>
            <if test="sticktime != null">
                STICKTIME,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="browser != null">
                #{browser,jdbcType=VARCHAR},
            </if>
            <if test="os != null">
                #{os,jdbcType=VARCHAR},
            </if>
            <if test="screen != null">
                #{screen,jdbcType=VARCHAR},
            </if>
            <if test="color != null">
                #{color,jdbcType=VARCHAR},
            </if>
            <if test="cookie != null">
                #{cookie,jdbcType=VARCHAR},
            </if>
            <if test="lang != null">
                #{lang,jdbcType=VARCHAR},
            </if>
            <if test="charset != null">
                #{charset,jdbcType=VARCHAR},
            </if>
            <if test="appid != null">
                #{appid,jdbcType=VARCHAR},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="url != null">
                #{url,jdbcType=VARCHAR},
            </if>
            <if test="host != null">
                #{host,jdbcType=VARCHAR},
            </if>
            <if test="ip != null">
                #{ip,jdbcType=VARCHAR},
            </if>
            <if test="tm != null">
                #{tm,jdbcType=TIMESTAMP},
            </if>
            <if test="vistor != null">
                #{vistor,jdbcType=VARCHAR},
            </if>
            <if test="sticktime != null">
                #{sticktime,jdbcType=DECIMAL},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.interfaces.domain.PtStat">
        update PT_STAT
        <set>
            <if test="browser != null">
                BROWSER = #{browser,jdbcType=VARCHAR},
            </if>
            <if test="os != null">
                OS = #{os,jdbcType=VARCHAR},
            </if>
            <if test="screen != null">
                SCREEN = #{screen,jdbcType=VARCHAR},
            </if>
            <if test="color != null">
                COLOR = #{color,jdbcType=VARCHAR},
            </if>
            <if test="cookie != null">
                COOKIE = #{cookie,jdbcType=VARCHAR},
            </if>
            <if test="lang != null">
                LANG = #{lang,jdbcType=VARCHAR},
            </if>
            <if test="charset != null">
                CHARSET = #{charset,jdbcType=VARCHAR},
            </if>
            <if test="appid != null">
                APPID = #{appid,jdbcType=VARCHAR},
            </if>
            <if test="title != null">
                TITLE = #{title,jdbcType=VARCHAR},
            </if>
            <if test="url != null">
                URL = #{url,jdbcType=VARCHAR},
            </if>
            <if test="host != null">
                HOST = #{host,jdbcType=VARCHAR},
            </if>
            <if test="ip != null">
                IP = #{ip,jdbcType=VARCHAR},
            </if>
            <if test="tm != null">
                TM = #{tm,jdbcType=TIMESTAMP},
            </if>
            <if test="vistor != null">
                VISTOR = #{vistor,jdbcType=VARCHAR},
            </if>
            <if test="sticktime != null">
                STICKTIME = #{sticktime,jdbcType=DECIMAL},
            </if>
        </set>
        where ID = #{id,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ruoyi.interfaces.domain.PtStat">
        update PT_STAT
        set BROWSER   = #{browser,jdbcType=VARCHAR},
            OS        = #{os,jdbcType=VARCHAR},
            SCREEN    = #{screen,jdbcType=VARCHAR},
            COLOR     = #{color,jdbcType=VARCHAR},
            COOKIE    = #{cookie,jdbcType=VARCHAR},
            LANG      = #{lang,jdbcType=VARCHAR},
            CHARSET   = #{charset,jdbcType=VARCHAR},
            APPID     = #{appid,jdbcType=VARCHAR},
            TITLE     = #{title,jdbcType=VARCHAR},
            URL       = #{url,jdbcType=VARCHAR},
            HOST      = #{host,jdbcType=VARCHAR},
            IP        = #{ip,jdbcType=VARCHAR},
            TM        = #{tm,jdbcType=TIMESTAMP},
            VISTOR    = #{vistor,jdbcType=VARCHAR},
            STICKTIME = #{sticktime,jdbcType=DECIMAL}
        where ID = #{id,jdbcType=VARCHAR}
    </update>


    <!-- 一一一一一一一一一一一一操作系统一一一一一一一一一一一一 -->
    <!--按操作系统统计-今天-->
    <select id="selectByOsToday" resultMap="BaseResultMap">
        select os, count(*) num
        from pt_stat
        where os is not null
          and tm &gt;= trunc(sysdate)
          and tm &lt; trunc(sysdate) + 1
        group by os
        order by num desc
    </select>

    <!--按操作系统统计-最近三天-->
    <select id="selectOSThree" resultMap="BaseResultMap">
        select os, count(*) num
        from pt_stat
        where os is not null
          and tm &gt;= trunc(sysdate) - 3
        group by os
        order by num desc
    </select>

    <!--按操作系统统计-最近一周-->
    <select id="selectOSWeek" resultMap="BaseResultMap">
        select os, count(*) num
        from pt_stat
        where os is not null
          and tm &gt;= trunc(sysdate) - 7
        group by os
        order by num desc
    </select>

    <!--按操作系统统计-累计-->
    <select id="selectByOs" resultMap="BaseResultMap">
        select os, count(*) num
        from pt_stat
        where os is not null
        group by os
        order by num desc
    </select>

    <!--按操作系统分析-折线图 -->
    <select id="selectAllOs" resultMap="BaseResultMap">
        select os, to_char(t.tm, 'YYYY-MM-DD') day, count(*) num
        from pt_stat t
        where os is not null
        group by os, to_char(t.tm, 'YYYY-MM-DD')
        order by day asc
    </select>

    <!--按操作系统分析-查看日期-折线图 -->
    <select id="selectOsDay" resultMap="BaseResultMap">
        select DISTINCT day
        FROM (select os, to_char(t.tm, 'YYYY-MM-DD') day, count (*) num from pt_stat t
            where os is not null
            group by os, to_char(t.tm, 'YYYY-MM-DD'))
        order by day asc
    </select>


    <!-- 一一一一一一一一一一一一分辨率一一一一一一一一一一一一 -->
    <!--按屏幕分辨率统计-今天-->
    <select id="selectByScreenToday" resultMap="BaseResultMap">
        select screen, count(*) num
        from pt_stat
        where screen is not null
          and tm &gt;= trunc(sysdate)
          and tm &lt; trunc(sysdate) + 1
        group by screen
        order by num desc
    </select>

    <!--最近三天-->
    <select id="selectScreenThree" resultMap="BaseResultMap">
        select *
        from (select screen, count(*) num
              from pt_stat
              where screen is not null
                and tm &gt;= trunc(sysdate) - 3
              group by screen
              order by num desc)
        where rownum &lt;= 10
    </select>


    <!--最近一周-->
    <select id="selectScreenWeek" resultMap="BaseResultMap">
        select *
        from (select screen, count(*) num
              from pt_stat
              where screen is not null
                and tm &gt;= trunc(sysdate) - 7
              group by screen
              order by num desc)
        where rownum &lt;= 10

    </select>

    <!--按屏幕分辨率统计-累计-->
    <select id="selectByScreen" resultMap="BaseResultMap">
        select *
        from (select screen, count(*) num from pt_stat where screen is not null group by screen order by num desc)
        where rownum &lt;= 10
    </select>

    <!--每天的数据=点击事件 -->
    <select id="selectDayByScreen" resultMap="BaseResultMap" parameterType="string">
        select to_char(t.tm, 'YYYY-MM-DD') day, count(*) num
        from pt_stat t
        where screen = #{screen,jdbcType=VARCHAR}
        group by to_char(t.tm, 'YYYY-MM-DD')
        order by day asc
    </select>


    <!-- 一一一一一一一一一一一一按应用系统分析 （总统计）一一一一一一一一一一一一 -->
    <!--按应用系统分析 （总统计）-今天 -->
    <select id="selectAppToday" resultMap="BaseResultMap">
        select appid, title, count(*) num
        from pt_stat
        where browser is not null
          and tm &gt;= trunc(sysdate)
          and tm &lt; trunc(sysdate) + 1
        group by appid, title
        order by num asc
    </select>

    <!--最近三天 -->
    <select id="selectAppThree" resultMap="BaseResultMap">
        select appid, title, count(*) num
        from pt_stat
        where browser is not null
          and tm &gt;= trunc(sysdate) - 3
        group by appid, title
        order by num asc
    </select>

    <!--最近一周-->
    <select id="selectAppWeek" resultMap="BaseResultMap">
        select appid, title, count(*) num
        from pt_stat
        where browser is not null
          and tm &gt;= trunc(sysdate) - 7
        group by appid, title
        order by num asc
    </select>

    <!--按应用系统分析 （总统计）-累计 -->
    <select id="selectAppAll" resultMap="BaseResultMap">
        select appid, title, count(*) num
        from pt_stat
        where browser is not null
        group by appid, title
        order by num asc
    </select>


    <!--某应用按日期统计-点击事件 -->
    <select id="selectByDay" resultMap="BaseResultMap" parameterType="string">
        select to_char(t.tm, 'YYYY-MM-DD') as day,sum(1) as cnt
        from pt_stat t
        where appid = #{appid,jdbcType=VARCHAR}
        group by to_char(t.tm, 'YYYY-MM-DD')
        order by day asc
    </select>


    <!-- 一一一一一一一一一一一一浏览器一一一一一一一一一一一一 -->
    <!--按浏览器统计-今天-->
    <select id="selectBrowserToday" resultMap="BaseResultMap">
        select browser, count(*) num
        from pt_stat
        where browser is not null
          and tm &gt;= trunc(sysdate)
          and tm &lt; trunc(sysdate) + 1
        group by browser
        order by num desc
    </select>

    <!--最近三天-->
    <select id="selectBroThree" resultMap="BaseResultMap">
        select browser, count(*) num
        from pt_stat
        where browser is not null
          and tm &gt;= trunc(sysdate) - 3
        group by browser
        order by num desc
    </select>

    <!--最近一周-->
    <select id="selectBroWeek" resultMap="BaseResultMap">
        select browser, count(*) num
        from pt_stat
        where browser is not null
          and tm &gt;= trunc(sysdate) - 7
        group by browser
        order by num desc
    </select>

    <!--按浏览器统计-累计-->
    <select id="selectBrowserAll" resultMap="BaseResultMap">
        select browser, count(*) num
        from pt_stat
        where browser is not null
        group by browser
        order by num desc
    </select>

    <!--每天的数据=点击事件 -->
    <select id="selectDayByBrowser" resultMap="BaseResultMap" parameterType="string">
        select to_char(t.tm, 'YYYY-MM-DD') day, count(*) num
        from pt_stat t
        where browser = #{browser,jdbcType=VARCHAR}
        group by to_char(t.tm, 'YYYY-MM-DD')
        order by day asc
    </select>


</mapper>
