<?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_shate.DateUploadMapper">
    <resultMap id="RM_Upload" type="com.ruoyi.system.domain_shate.DateUpload">

        <result property="id" column="ID"/>
        <result property="zone" column="Zone"/>
        <result property="link" column="link"/>
        <result property="fileName" column="file_name"/>
        <result property="dataTime" column="data_time"/>
        <result property="type" column="type"/>
        <result property="type1" column="type1"/>
        <result property="type2" column="type2"/>
        <result property="year" column="year1"/>
        <result property="createdTime" column="created_time"/>
        <result property="data_id" column="data_id"/>
        <result property="area" column="area"/>
        <result property="band_index" column="band_index"/>
        <result property="bands" column="bands"/>
        <result property="cols" column="cols"/>
        <result property="depth" column="depth"/>
        <result property="description" column="description"/>
        <result property="extent1" column="extent"/>
        <result property="name" column="name"/>
        <result property="projection" column="projection"/>
        <result property="resolution" column="resolution"/>
        <result property="size" column="size"/>
        <result property="month" column="month"/>
        <result property="route" column="route"/>

    </resultMap>

    <sql id="columns">
	    <![CDATA[
        ID,Zone,data_id ,year1,route,link,type,month ,type1,type2,file_name,data_time,created_time,type,data_id,area,band_index,bands,cols,depth,description,extent,name,projection,resolution,size
        ]]>
	</sql>



    <select id="selectShp" resultMap="RM_Upload">

        SELECT  <include refid="columns"/>  FROM  data_upload

        WHERE 1=1
        and type1 ='BOUNDARIES'

        <if test="zone!= null and zone !=''">
            AND zone = #{zone}
        </if>

        <if test="type!= null and type !=''">
            AND type = #{type}
        </if>

        <!--        <if test="dateTime!= null and dateTime !=''">-->
        <!--            AND data_time = #{dateTime}-->
        <!--        </if>-->

    </select>

    <select id="selectUpload" resultMap="RM_Upload">
        SELECT  <include refid="columns"/>  FROM  data_upload
        WHERE 1=1

        <if test="zone!= null and zone !=''">
            AND zone = #{zone}
        </if>

        <if test="type!= null and type !=''">
            AND type = #{type}
        </if>

        <if test="type1!= null and type1 !=''">
            AND type1 = #{type1}
        </if>

        <if test="type2!= null and type2 !=''">
            AND type2 = #{type2}
        </if>
        <if test="year!= null and year !=''">
            AND year1 = #{year}
        </if>

        <if test="dateWithSway!= null and dateWithSway !=''">
            AND created_Time = #{dateWithSway}
        </if>

        <if test="name!= null and name !=''">
            AND file_name like #{name}
        </if>

        <if test="dateTime != null and dateTime !=''">
            AND data_time=#{dateTime}
        </if>
        ORDER BY created_time desc
    </select>

    <select id="selectShpfile" resultMap="RM_Upload">
        SELECT  <include refid="columns"/>  FROM  data_upload
        WHERE 1=1

        <if test="zone!= null and zone !=''">
            AND zone = #{zone}
        </if>

        <if test="type!= null and type !=''">
            AND type = #{type}
        </if>

        <if test="dateTime!= null and dateTime !=''">
            AND data_time = #{dateTime}
        </if>

    </select>


    <select id="selectDel" resultMap="RM_Upload">
        SELECT  <include refid="columns"/>  FROM  data_upload
        WHERE ID=#{id}
    </select>

    <delete id="DelUpload">
        DELETE FROM Data_Upload
        WHERE ID=#{id}
    </delete>


    <delete id="DelShp">
        DELETE FROM shp_upload
        WHERE ID=#{id}
    </delete>

    <insert id="IntoUpload">
        <![CDATA[
        INSERT INTO Data_Upload (
            zone ,
            type ,
            type1 ,
            type2,
            year1,
            link,
            file_name ,
            data_time ,
            data_id,
            area,
            band_index,
            bands,
            cols,
            depth,
            description,
            extent,
            name,
            projection,
            resolution,
            size,
            route,
            month,
            created_time
        ) VALUES (
                     #{zone,jdbcType=VARCHAR},
                     #{type,jdbcType=VARCHAR},
                     #{type1,jdbcType=VARCHAR},
                     #{type2,jdbcType=VARCHAR},
                     #{year,jdbcType=VARCHAR},
                     #{link,jdbcType=VARCHAR},
                     #{fileName,jdbcType=VARCHAR},
                     #{dataTime,jdbcType=VARCHAR},
                     #{data_id,jdbcType=VARCHAR},
                     #{area,jdbcType=VARCHAR},
                     #{band_index,jdbcType=VARCHAR},
                     #{bands,jdbcType=VARCHAR},
                     #{cols,jdbcType=VARCHAR},
                     #{depth,jdbcType=VARCHAR},
                     #{description,jdbcType=VARCHAR},
                     #{extent1,jdbcType=VARCHAR},
                     #{name,jdbcType=VARCHAR},
                     #{projection,jdbcType=VARCHAR},
                     #{resolution,jdbcType=VARCHAR},
                     #{size,jdbcType=DOUBLE},
                     #{route,jdbcType=VARCHAR},
                     #{month,jdbcType=INTEGER},
                     #{createdTime,jdbcType=VARCHAR}
                 )
        ]]>
    </insert>

    <insert id="IntoShp">
        <![CDATA[
        INSERT INTO shp_upload (
            zone ,
            type ,
            type1 ,
            link,
            file_name ,
            data_time
        ) VALUES (
                     #{zone,jdbcType=VARCHAR},
                     #{type,jdbcType=VARCHAR},
                     #{type1,jdbcType=VARCHAR},
                     #{link,jdbcType=VARCHAR},
                     #{fileName,jdbcType=VARCHAR},
                     #{dataTime,jdbcType=VARCHAR}
                 )
        ]]>
    </insert>

    <delete id="altitude">
        DELETE FROM altitude
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="aspect">
        DELETE FROM aspect
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="landuse">
        DELETE FROM landuse
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="suitability">
        DELETE FROM suitability
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="road">
        DELETE FROM road
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="seedSuccess">
        DELETE FROM #{seed_Success}
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="vegetationDistribution">
        DELETE FROM "vegetation_Distribution"
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="slope">
        DELETE FROM slope
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="desertification">
        DELETE FROM desertification
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="moisture">
        DELETE FROM moisture
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="salinization">
        DELETE FROM salinization
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="healthy">
        DELETE FROM healthy
        WHERE zone = #{zone}
          and image_date =#{imageDate}
          and resolution=#{resolution}
    </delete>

    <delete id="water">
        DELETE FROM water
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="waterArea">
        DELETE FROM water_area
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="roadLength">
        DELETE FROM road_length
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>

    <delete id="climateIndex">
        DELETE FROM climate_index
        WHERE zone = #{zone}
          and image_date =#{imageDate}
    </delete>



</mapper>