<?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.system.mapper.MeasureUploadMapper">

    <resultMap type="com.ruoyi.system.domain.MeasureUpload" id="MeasureUploadMap">
        <result property="measureId" column="measure_id" jdbcType="INTEGER"/>
        <result property="planid" column="planid" jdbcType="INTEGER"/>
        <result property="pn" column="pn" jdbcType="INTEGER"/>
        <result property="wspeed" column="wspeed" jdbcType="NUMERIC"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="siteId" column="site_id" jdbcType="INTEGER"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="taskid" column="taskid" jdbcType="VARCHAR"/>
        <result property="waterlevel" column="waterlevel" jdbcType="NUMERIC"/>
        <result property="pointX" column="point_x" jdbcType="NUMERIC"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="MeasureUploadMap">
        select
            measure_id, planid, pn, wspeed, create_time, site_id, status, id, taskid, waterlevel, point_x
        from measure_upload
        where measure_id = #{measureId}
    </select>

    <!--查询多个-->
    <select id="queryBySiteIdTime" resultMap="MeasureUploadMap">
        select
            measure_id, planid, pn, wspeed, create_time, site_id, status, id, taskid, waterlevel, point_x
        from measure_upload
        where site_id = #{siteId}
        <if test="createTime != null">
            and create_time >= #{createTime}
        </if>
        <if test="taskid != null and taskid != ''">
            and taskid = #{taskid}
        </if>
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="MeasureUploadMap">
        select
            measure_id, planid, pn, wspeed, create_time, site_id, status, id, taskid, waterlevel, point_x
        from measure_upload
        <where>
            <if test="measureId != null">
                and measure_id = #{measureId}
            </if>
            <if test="planid != null">
                and planid = #{planid}
            </if>
            <if test="pn != null">
                and pn = #{pn}
            </if>
            <if test="wspeed != null">
                and wspeed = #{wspeed}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="siteId != null">
                and site_id = #{siteId}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="id != null and id != ''">
                and id = #{id}
            </if>
            <if test="taskid != null and taskid != ''">
                and taskid = #{taskid}
            </if>
            <if test="waterlevel != null">
                and waterlevel = #{waterlevel}
            </if>
            <if test="pointX != null">
                and point_x = #{pointX}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from measure_upload
        <where>
            <if test="measureId != null">
                and measure_id = #{measureId}
            </if>
            <if test="planid != null">
                and planid = #{planid}
            </if>
            <if test="pn != null">
                and pn = #{pn}
            </if>
            <if test="wspeed != null">
                and wspeed = #{wspeed}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="siteId != null">
                and site_id = #{siteId}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="id != null and id != ''">
                and id = #{id}
            </if>
            <if test="taskid != null and taskid != ''">
                and taskid = #{taskid}
            </if>
            <if test="waterlevel != null">
                and waterlevel = #{waterlevel}
            </if>
            <if test="pointX != null">
                and point_x = #{pointX}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="measureId" useGeneratedKeys="true">
        insert into measure_upload(planid, pn, wspeed, create_time, site_id, status, id, taskid, waterlevel, point_x)
        values (#{planid}, #{pn}, #{wspeed}, #{createTime}, #{siteId}, #{status},#{id},#{taskid},#{waterlevel},#{pointX})
    </insert>

    <insert id="insertBatch" keyProperty="measureId" useGeneratedKeys="true">
        insert into measure_upload(planid, pn, wspeed, create_time, site_id, status,id, taskid, waterlevel, point_x)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.planid}, #{entity.pn}, #{entity.wspeed}, #{entity.createTime}, #{entity.siteId}, #{entity.status},#{entity.id},#{entity.taskid},#{entity.waterlevel},#{entity.pointX})
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="measureId" useGeneratedKeys="true">
        insert into measure_upload(planid, pn, wspeed, create_time, site_id, status, id, taskid, waterlevel, point_x)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.planid}, #{entity.pn}, #{entity.wspeed}, #{entity.createTime}, #{entity.siteId}, #{entity.status}, #{entity.id},#{entity.taskid},#{entity.waterlevel},#{entity.pointX})
        </foreach>
        on duplicate key update
        planid = values(planid),
        pn = values(pn),
        wspeed = values(wspeed),
        create_time = values(create_time),
        site_id = values(site_id),
        status = values(status),
        id = values(id),
        taskid = values(taskid),
        waterlevel = values(waterlevel),
        point_x = values(point_x)
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update measure_upload
        <set>
            <if test="planid != null">
                planid = #{planid},
            </if>
            <if test="pn != null">
                pn = #{pn},
            </if>
            <if test="wspeed != null">
                wspeed = #{wspeed},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="siteId != null">
                site_id = #{siteId},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="id != null">
                id = #{id},
            </if>
            <if test="taskid != null">
                taskid = #{taskid},
            </if>
            <if test="waterlevel != null">
                waterlevel = #{waterlevel},
            </if>
            <if test="pointX != null">
                point_x = #{pointX},
            </if>
        </set>
        where measure_id = #{measureId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from measure_upload where measure_id = #{measureId}
    </delete>

</mapper>

