<?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.fs.statis.mapper.FsStatisPeriodWatchMapper">

    <!-- 通用查询结果映射 -->
    <resultMap id="BaseResultMap" type="com.fs.statis.domain.FsStatisPeriodWatch">
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="period_id" property="periodId" jdbcType="INTEGER" />
        <result column="period_num" property="periodNum" jdbcType="INTEGER" />
        <result column="not_reg_num" property="notRegNum" jdbcType="INTEGER" />
        <result column="registered_num" property="registeredNum" jdbcType="INTEGER" />
        <result column="reg_rate" property="regRate" jdbcType="DECIMAL" />
        <result column="watch_completed_rate" property="watchCompletedRate" jdbcType="DECIMAL" />
        <result column="offline_total" property="offlineTotal" jdbcType="INTEGER" />
        <result column="offline_not_reg_num" property="offlineNotRegNum" jdbcType="INTEGER" />
        <result column="offline_not_watch_num" property="offlineNotWatchNum" jdbcType="INTEGER" />
        <result column="online_total" property="onlineTotal" jdbcType="INTEGER" />
        <result column="online_rate" property="onlineRate" jdbcType="DECIMAL" />
        <result column="online_watch_completed_rate" property="onlineWatchCompletedRate" jdbcType="DECIMAL" />
        <result column="online_watch_not_completed" property="onlineWatchNotCompleted" jdbcType="INTEGER" />
        <result column="online_watch_completed" property="onlineWatchCompleted" jdbcType="INTEGER" />
        <result column="data_date" property="dataDate" jdbcType="DATE" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, period_id, period_num, not_reg_num, registered_num, reg_rate,
        watch_completed_rate, offline_total, offline_not_reg_num, offline_not_watch_num,
        online_total, online_rate, online_watch_completed_rate, online_watch_not_completed,
        online_watch_completed, data_date
    </sql>

    <!-- 查询所有数据 -->
    <select id="selectAll" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM fs_statis_period_watch
    </select>
    <select id="queryList" resultType="com.fs.statis.domain.FsStatisPeriodWatch">
        select * from fs_statis_period_watch
        <where>
            <if test="userIds != null and userIds.length > 0">
                AND company_user_id IN
                <foreach collection="userIds" open="(" close=")" separator="," item="item">
                    ${item}
                </foreach>
            </if>
            <if test="periodList != null and periodList.size() > 0">
                AND period_id IN
                <foreach collection="periodList" open="(" close=")" separator="," item="item">
                    ${item}
                </foreach>
            </if>
            <if test="startDate != null and endDate != null">
                AND data_date BETWEEN #{startDate} AND #{endDate}
            </if>
        </where>
    </select>
    <select id="selectRecords" resultType="com.fs.sop.domain.SopUserLogs">
        select id,qw_user_id from sop_user_logs
        <where>
            <if test="status != null">
                AND status = 1
            </if>
            <if test="previousDay != null">
                AND start_time = #{previousDay}
            </if>
        </where>
    </select>


</mapper>
