<?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.siwei.rsmonitoring.mapper.TDkGeomDbMapper">

    <resultMap type="TDkGeomDb" id="TDkGeomDbResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="shppath"    column="shppath"    />
        <result property="filetype"    column="filetype"    />
        <result property="geom"    column="geom"    />
        <result property="geomNumber"    column="geom_number"    />
        <result property="geomArea"    column="geom_area"    />
        <result property="fromroute"    column="fromroute"    />
        <result property="status"    column="status"    />
        <result property="message"    column="message"    />
        <result property="updateNumberCheckSuccess"    column="update_number_check_success"    />
        <result property="updateNumberCheckFull"    column="update_number_check_full"    />
        <result property="updateNumberSuccess"    column="update_number_success"    />
        <result property="updateNumberFull"    column="update_number_full"    />
        <result property="updateMessage"    column="update_message"    />
        <result property="dataType"    column="data_type"    />
    </resultMap>

    <sql id="selectTDkGeomDbVo">
        select id, name, create_by, create_time, shppath, filetype, public.st_asewkt(geom) AS  geom, geom_number, geom_area,data_type
             , fromroute,status,message, update_number_check_success, update_number_check_full, update_number_success, update_number_full,
               update_message,update_by,update_time,data_type from t_dk_geom_db
    </sql>

    <select id="selectTDkGeomDbList" parameterType="TDkGeomDb" resultMap="TDkGeomDbResult">
        <include refid="selectTDkGeomDbVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="shppath != null  and shppath != ''"> and shppath = #{shppath}</if>
            <if test="filetype != null  and filetype != ''"> and filetype = #{filetype}</if>
            <if test="geomNumber != null  and geomNumber != ''"> and geom_number = #{geomNumber}</if>
            <if test="fromroute != null  and fromroute != ''"> and fromroute = #{fromroute}</if>
            <if test="dataType != null  and dataType != ''"> and data_type = #{dataType}</if>
            <if test="startTime != null"> and create_time &gt;= #{startTime}</if>
            <if test="endTime != null"> and create_time &lt;= #{endTime}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectTDkGeomDbById" parameterType="String" resultMap="TDkGeomDbResult">
        <include refid="selectTDkGeomDbVo"/>
        where id = #{id}
    </select>

    <insert id="insertTDkGeomDb" parameterType="TDkGeomDb">
        insert into t_dk_geom_db
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="name != null">name,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="shppath != null">shppath,</if>
            <if test="filetype != null">filetype,</if>
            <if test="geom != null">geom,</if>
            <if test="geomNumber != null">geom_number,</if>
            <if test="geomArea != null">geom_area,</if>
            <if test="fromroute != null">fromroute,</if>
            <if test="status != null">status,</if>
            <if test="message != null">message,</if>
            <if test="updateNumberCheckSuccess != null">update_number_check_success,</if>
            <if test="updateNumberCheckFull != null">update_number_check_full,</if>
            <if test="updateNumberSuccess != null">update_number_success,</if>
            <if test="updateNumberFull != null">update_number_full,</if>
            <if test="updateMessage != null">update_message,</if>
            <if test="dataType != null and dataType != ''">data_type,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="updateTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="shppath != null">#{shppath},</if>
            <if test="filetype != null">#{filetype},</if>
            <if test="geom != null">public.st_geomfromewkt(#{geom}),</if>
            <if test="geomNumber != null">#{geomNumber},</if>
            <if test="geomArea != null">#{geomArea},</if>
            <if test="fromroute != null">#{fromroute},</if>
            <if test="status != null">#{status},</if>
            <if test="message != null">#{message},</if>
            <if test="updateNumberCheckSuccess != null">#{updateNumberCheckSuccess},</if>
            <if test="updateNumberCheckFull != null">#{updateNumberCheckFull},</if>
            <if test="updateNumberSuccess != null">#{updateNumberSuccess},</if>
            <if test="updateNumberFull != null">#{updateNumberFull},</if>
            <if test="updateMessage != null">#{updateMessage},</if>
            <if test="dataType != null and dataType != ''">#{dataType},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTDkGeomDb" parameterType="TDkGeomDb">
        update t_dk_geom_db
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="shppath != null">shppath = #{shppath},</if>
            <if test="filetype != null">filetype = #{filetype},</if>
            <if test="geom != null and geom != ''">geom = public.st_geomfromewkt(#{geom}),</if>
            <if test="geomNumber != null">geom_number = #{geomNumber},</if>
            <if test="geomArea != null">geom_area = #{geomArea},</if>
            <if test="fromroute != null and fromroute != '' ">fromroute = #{fromroute},</if>
            <if test="updateNumberCheckSuccess != null">update_number_check_success=#{updateNumberCheckSuccess},</if>
            <if test="updateNumberCheckFull != null">update_number_check_full=#{updateNumberCheckFull},</if>
            <if test="updateNumberSuccess != null">update_number_success=#{updateNumberSuccess},</if>
            <if test="updateNumberFull != null">update_number_full=#{updateNumberFull},</if>
            <if test="updateMessage != null and updateMessage != ''">update_message=#{updateMessage},</if>
            <if test="status != null and status != ''">status=#{status},</if>
            <if test="dataType != null and dataType != ''">data_type=#{dataType},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTDkGeomDbById" parameterType="String">
        delete from t_dk_geom_db where id = #{id}
    </delete>

    <delete id="deleteTDkGeomDbByIds" parameterType="String">
        delete from t_dk_geom_db where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>