<?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.ho.business.mapper.GateValueMapper">


    <sql id="Base_Column_List">
        id
        ,group_id,dept_id,
        station_id,create_time,type,
        digital,day
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from gate_value
        where id = #{id,jdbcType=INTEGER}
    </select>

    <select id="getStatisticsList" resultType="com.ho.business.vo.resp.StatisticsRespVO">
        select day as date , digital
        from gate_value
        <where>
            <if test="beginTime != null ">
                and day &gt;=  #{beginTime}
            </if>
            <if test="endTime != null">
                and day &lt;= #{endTime}
            </if>
            <if test="stationId != null">
                and station_id = #{stationId}
            </if>
            <if test="groupId != null">
                and group_id = #{groupId}
            </if>
            <if test="deptId != null">
                and dept_id = #{deptId}
            </if>
            <if test="type !=null">
                and type = #{type}
            </if>
        </where>
        order by day
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from gate_value
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.GateValue"
            useGeneratedKeys="true">
        insert into gate_value
        ( id, group_id, dept_id
        , station_id, create_time, type
        , digital, day)
        values ( #{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}
               , #{stationId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER}
               , #{digital,jdbcType=DECIMAL}, #{day,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.GateValue"
            useGeneratedKeys="true">
        insert into gate_value
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="groupId != null">group_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="stationId != null">station_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="type != null">type,</if>
            <if test="digital != null">digital,</if>
            <if test="day != null">day,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=INTEGER},</if>
            <if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
            <if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
            <if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="digital != null">#{digital,jdbcType=DECIMAL},</if>
            <if test="day != null">#{day,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.GateValue">
        update gate_value
        <set>
            <if test="groupId != null">
                group_id = #{groupId,jdbcType=INTEGER},
            </if>
            <if test="deptId != null">
                dept_id = #{deptId,jdbcType=INTEGER},
            </if>
            <if test="stationId != null">
                station_id = #{stationId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=INTEGER},
            </if>
            <if test="digital != null">
                digital = #{digital,jdbcType=DECIMAL},
            </if>
            <if test="day != null">
                day = #{day,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ho.business.entity.GateValue">
        update gate_value
        set group_id    = #{groupId,jdbcType=INTEGER},
            dept_id     = #{deptId,jdbcType=INTEGER},
            station_id  = #{stationId,jdbcType=INTEGER},
            create_time = #{createTime,jdbcType=TIMESTAMP},
            type        = #{type,jdbcType=INTEGER},
            digital     = #{digital,jdbcType=DECIMAL},
            day         = #{day,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>
