<?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.shanghaichengdi.ghjgitem.mapper.WaterLevelDataMapper">

    <resultMap id="BaseResultMap" type="com.shanghaichengdi.ghjgitem.domain.WaterLevelData">
            <id property="id" column="ID" jdbcType="VARCHAR"/>
            <result property="devId" column="DEV_ID" jdbcType="DECIMAL"/>
            <result property="at" column="AT" jdbcType="VARCHAR"/>
            <result property="code" column="CODE" jdbcType="VARCHAR"/>
            <result property="codeName" column="CODE_NAME" jdbcType="VARCHAR"/>
            <result property="codeStDescription" column="CODE_ST_DESCRIPTION" jdbcType="VARCHAR"/>
            <result property="host" column="HOST" jdbcType="VARCHAR"/>
            <result property="loop" column="LOOP" jdbcType="VARCHAR"/>
            <result property="point" column="POINT" jdbcType="VARCHAR"/>
            <result property="partition" column="PARTITION" jdbcType="VARCHAR"/>
            <result property="type" column="TYPE" jdbcType="VARCHAR"/>
            <result property="auxTypeInfo" column="AUX_TYPE_INFO" jdbcType="VARCHAR"/>
            <result property="wtime" column="WTIME" jdbcType="TIMESTAMP"/>
            <result property="devAdd" column="DEV_ADD" jdbcType="VARCHAR"/>
            <result property="devPos" column="DEV_POS" jdbcType="VARCHAR"/>
            <result property="contact" column="CONTACT" jdbcType="VARCHAR"/>
            <result property="b1" column="B1" jdbcType="VARCHAR"/>
            <result property="b2" column="B2" jdbcType="VARCHAR"/>
            <result property="b3" column="B3" jdbcType="VARCHAR"/>
            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        ID,DEV_ID,AT,
        CODE,CODE_NAME,CODE_ST_DESCRIPTION,
        HOST,LOOP,POINT,
        PARTITION,TYPE,AUX_TYPE_INFO,
        WTIME,DEV_ADD,DEV_POS,
        CONTACT,B1,B2,
        B3,CREATE_TIME
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from WATER_LEVEL_DATA
        where  ID = #{id,jdbcType=VARCHAR} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from WATER_LEVEL_DATA
        where  ID = #{id,jdbcType=VARCHAR} 
    </delete>
    <insert id="insert" keyColumn="ID" keyProperty="id" parameterType="com.shanghaichengdi.ghjgitem.domain.WaterLevelData" useGeneratedKeys="true">
        insert into WATER_LEVEL_DATA
        ( ID,DEV_ID,AT
        ,CODE,CODE_NAME,CODE_ST_DESCRIPTION
        ,HOST,LOOP,POINT
        ,PARTITION,TYPE,AUX_TYPE_INFO
        ,WTIME,DEV_ADD,DEV_POS
        ,CONTACT,B1,B2
        ,B3,CREATE_TIME)
        values (#{id,jdbcType=VARCHAR},#{devId,jdbcType=DECIMAL},#{at,jdbcType=VARCHAR}
        ,#{code,jdbcType=VARCHAR},#{codeName,jdbcType=VARCHAR},#{codeStDescription,jdbcType=VARCHAR}
        ,#{host,jdbcType=VARCHAR},#{loop,jdbcType=VARCHAR},#{point,jdbcType=VARCHAR}
        ,#{partition,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{auxTypeInfo,jdbcType=VARCHAR}
        ,#{wtime,jdbcType=TIMESTAMP},#{devAdd,jdbcType=VARCHAR},#{devPos,jdbcType=VARCHAR}
        ,#{contact,jdbcType=VARCHAR},#{b1,jdbcType=VARCHAR},#{b2,jdbcType=VARCHAR}
        ,#{b3,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="ID" keyProperty="id" parameterType="com.shanghaichengdi.ghjgitem.domain.WaterLevelData" useGeneratedKeys="true">
        insert into WATER_LEVEL_DATA
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">ID,</if>
                <if test="devId != null">DEV_ID,</if>
                <if test="at != null">AT,</if>
                <if test="code != null">CODE,</if>
                <if test="codeName != null">CODE_NAME,</if>
                <if test="codeStDescription != null">CODE_ST_DESCRIPTION,</if>
                <if test="host != null">HOST,</if>
                <if test="loop != null">LOOP,</if>
                <if test="point != null">POINT,</if>
                <if test="partition != null">PARTITION,</if>
                <if test="type != null">TYPE,</if>
                <if test="auxTypeInfo != null">AUX_TYPE_INFO,</if>
                <if test="wtime != null">WTIME,</if>
                <if test="devAdd != null">DEV_ADD,</if>
                <if test="devPos != null">DEV_POS,</if>
                <if test="contact != null">CONTACT,</if>
                <if test="b1 != null">B1,</if>
                <if test="b2 != null">B2,</if>
                <if test="b3 != null">B3,</if>
                <if test="createTime != null">CREATE_TIME,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=VARCHAR},</if>
                <if test="devId != null">#{devId,jdbcType=DECIMAL},</if>
                <if test="at != null">#{at,jdbcType=VARCHAR},</if>
                <if test="code != null">#{code,jdbcType=VARCHAR},</if>
                <if test="codeName != null">#{codeName,jdbcType=VARCHAR},</if>
                <if test="codeStDescription != null">#{codeStDescription,jdbcType=VARCHAR},</if>
                <if test="host != null">#{host,jdbcType=VARCHAR},</if>
                <if test="loop != null">#{loop,jdbcType=VARCHAR},</if>
                <if test="point != null">#{point,jdbcType=VARCHAR},</if>
                <if test="partition != null">#{partition,jdbcType=VARCHAR},</if>
                <if test="type != null">#{type,jdbcType=VARCHAR},</if>
                <if test="auxTypeInfo != null">#{auxTypeInfo,jdbcType=VARCHAR},</if>
                <if test="wtime != null">#{wtime,jdbcType=TIMESTAMP},</if>
                <if test="devAdd != null">#{devAdd,jdbcType=VARCHAR},</if>
                <if test="devPos != null">#{devPos,jdbcType=VARCHAR},</if>
                <if test="contact != null">#{contact,jdbcType=VARCHAR},</if>
                <if test="b1 != null">#{b1,jdbcType=VARCHAR},</if>
                <if test="b2 != null">#{b2,jdbcType=VARCHAR},</if>
                <if test="b3 != null">#{b3,jdbcType=VARCHAR},</if>
                <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.shanghaichengdi.ghjgitem.domain.WaterLevelData">
        update WATER_LEVEL_DATA
        <set>
                <if test="devId != null">
                    DEV_ID = #{devId,jdbcType=DECIMAL},
                </if>
                <if test="at != null">
                    AT = #{at,jdbcType=VARCHAR},
                </if>
                <if test="code != null">
                    CODE = #{code,jdbcType=VARCHAR},
                </if>
                <if test="codeName != null">
                    CODE_NAME = #{codeName,jdbcType=VARCHAR},
                </if>
                <if test="codeStDescription != null">
                    CODE_ST_DESCRIPTION = #{codeStDescription,jdbcType=VARCHAR},
                </if>
                <if test="host != null">
                    HOST = #{host,jdbcType=VARCHAR},
                </if>
                <if test="loop != null">
                    LOOP = #{loop,jdbcType=VARCHAR},
                </if>
                <if test="point != null">
                    POINT = #{point,jdbcType=VARCHAR},
                </if>
                <if test="partition != null">
                    PARTITION = #{partition,jdbcType=VARCHAR},
                </if>
                <if test="type != null">
                    TYPE = #{type,jdbcType=VARCHAR},
                </if>
                <if test="auxTypeInfo != null">
                    AUX_TYPE_INFO = #{auxTypeInfo,jdbcType=VARCHAR},
                </if>
                <if test="wtime != null">
                    WTIME = #{wtime,jdbcType=TIMESTAMP},
                </if>
                <if test="devAdd != null">
                    DEV_ADD = #{devAdd,jdbcType=VARCHAR},
                </if>
                <if test="devPos != null">
                    DEV_POS = #{devPos,jdbcType=VARCHAR},
                </if>
                <if test="contact != null">
                    CONTACT = #{contact,jdbcType=VARCHAR},
                </if>
                <if test="b1 != null">
                    B1 = #{b1,jdbcType=VARCHAR},
                </if>
                <if test="b2 != null">
                    B2 = #{b2,jdbcType=VARCHAR},
                </if>
                <if test="b3 != null">
                    B3 = #{b3,jdbcType=VARCHAR},
                </if>
                <if test="createTime != null">
                    CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   ID = #{id,jdbcType=VARCHAR} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.shanghaichengdi.ghjgitem.domain.WaterLevelData">
        update WATER_LEVEL_DATA
        set 
            DEV_ID =  #{devId,jdbcType=DECIMAL},
            AT =  #{at,jdbcType=VARCHAR},
            CODE =  #{code,jdbcType=VARCHAR},
            CODE_NAME =  #{codeName,jdbcType=VARCHAR},
            CODE_ST_DESCRIPTION =  #{codeStDescription,jdbcType=VARCHAR},
            HOST =  #{host,jdbcType=VARCHAR},
            LOOP =  #{loop,jdbcType=VARCHAR},
            POINT =  #{point,jdbcType=VARCHAR},
            PARTITION =  #{partition,jdbcType=VARCHAR},
            TYPE =  #{type,jdbcType=VARCHAR},
            AUX_TYPE_INFO =  #{auxTypeInfo,jdbcType=VARCHAR},
            WTIME =  #{wtime,jdbcType=TIMESTAMP},
            DEV_ADD =  #{devAdd,jdbcType=VARCHAR},
            DEV_POS =  #{devPos,jdbcType=VARCHAR},
            CONTACT =  #{contact,jdbcType=VARCHAR},
            B1 =  #{b1,jdbcType=VARCHAR},
            B2 =  #{b2,jdbcType=VARCHAR},
            B3 =  #{b3,jdbcType=VARCHAR},
            CREATE_TIME =  #{createTime,jdbcType=TIMESTAMP}
        where   ID = #{id,jdbcType=VARCHAR} 
    </update>

    <select id="getDataByTime" resultType="com.shanghaichengdi.ghjgitem.domain.WaterLevelData">
        select t.id,t.dev_id,t.code,t.code_name,t.code_st_description,t.type,t.wtime,
               t.dev_add,t.dev_pos,t.contact,t.b1,t.b2,t.b3,t.create_time
        from GHJG_DYNAMIC.WATER_LEVEL_DATA t
        where t.wtime >= to_date(#{startTime},'yyyy-mm-dd hh24:mi:ss')
        and t.wtime &lt; to_date(#{endTime},'yyyy-mm-dd hh24:mi:ss')
    </select>
</mapper>
