<?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.TopographicFactorMapper">
    <resultMap id="RM_Altitude" type="com.ruoyi.system.domain_shate.Altitude">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <result property="regionName" column="region_name"/>
        <result property="level1" column="level1"/>
        <result property="level2" column="level2"/>
        <result property="level3" column="level3"/>
        <result property="level4" column="level4"/>
        <result property="level5" column="level5"/>
        <result property="imageDate" column="Image_date"/>
        <result property="year" column="year1"/>
        <result property="productCode1" column="Product_code1"/>
        <result property="productCode2" column="Product_code2"/>
        <result property="createdBy" column="created_by"/>
    </resultMap>


    <resultMap id="RM_Aspect" type="com.ruoyi.system.domain_shate.Aspect">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <result property="regionName" column="region_name"/>
        <result property="north" column="North"/>
        <result property="northeast" column="Northeast"/>
        <result property="east" column="East"/>
        <result property="southeast" column="Southeast"/>
        <result property="south" column="South"/>
        <result property="southwest" column="Southwest"/>
        <result property="west" column="West"/>
        <result property="northwest" column="Northwest"/>
        <result property="imageDate" column="Image_date"/>
        <result property="productCode1" column="Product_code1"/>
        <result property="productCode2" column="Product_code2"/>
        <result property="year" column="year1"/>
        <result property="createdBy" column="created_by"/>
        <result property="craeteTime" column="created_time"/>
    </resultMap>

    <resultMap id="RM_Slope" type="com.ruoyi.system.domain_shate.Slope">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <result property="regionName" column="region_name"/>
        <result property="level1" column="level1"/>
        <result property="level2" column="level2"/>
        <result property="level3" column="level3"/>
        <result property="level4" column="level4"/>
        <result property="level5" column="level5"/>
        <result property="imageDate" column="Image_date"/>
        <result property="productCode1" column="Product_code1"/>
        <result property="productCode2" column="Product_code2"/>
        <result property="year" column="year1"/>
        <result property="createdBy" column="created_by"/>
    </resultMap>

    <sql id="columns">
	    <![CDATA[
        ID,zone,region_name,level5,year1,level1,level2,level3,level4,Image_date,Product_code1,Product_code2,created_by
        ]]>
	</sql>

    <sql id="Aspect">
	    <![CDATA[
        ID,zone,region_name,north,year1,northeast,east,southeast,south,southwest,west,northwest,Image_date,Product_code1,Product_code2,created_by
        ]]>
	</sql>

    <select id="sqlAltitude" resultMap="RM_Altitude">
        SELECT  <include refid="columns"/>  FROM  Altitude
        WHERE 1=1
        <if test="zone!= null and zone !=''">
            AND zone = #{zone}
        </if>
        <if test="year!= null and year !=''">
            AND year1 = #{year}
        </if>
    </select>

    <select id="sqlYear" resultMap="RM_Altitude">
        SELECT  distinct year1,ZONE,region_name  FROM  Altitude

    </select>

    <select id="sqlSlope" resultMap="RM_Slope">
        SELECT  <include refid="columns"/>  FROM  Slope
        WHERE 1=1
        <if test="zone!= null and zone !=''">
            AND zone = #{zone}
        </if>
        <if test="year!= null and year !=''">
            AND year1 = #{year}
        </if>
    </select>

    <select id="sqlYear1" resultMap="RM_Slope">
        SELECT  distinct year1,ZONE,region_name FROM  Slope
    </select>

    <select id="sqlAspect" resultMap="RM_Aspect">
        SELECT  <include refid="Aspect"/>  FROM  Aspect
        WHERE 1=1
        <if test="zone!= null and zone !=''">
            AND zone = #{zone}
        </if>
        <if test="year!= null and year !=''">
            AND year1 = #{year}
        </if>
    </select>

    <select id="sqlYear2" resultMap="RM_Aspect">
        SELECT  distinct year1,ZONE,region_name   FROM  Aspect
    </select>

    <insert id="InsertAltitude">
        <![CDATA[
        INSERT INTO Altitude (
            zone ,
            region_name,
            level1,
            level2 ,
            level3 ,
            level4,
            level5,
            Image_date ,
            Product_code1 ,
            Product_code2,
            year1,
            created_by
        ) VALUES (
                     #{zone,jdbcType=VARCHAR},
                     #{zone,jdbcType=VARCHAR},
                     #{level1,jdbcType=DOUBLE},
                     #{level2,jdbcType=DOUBLE},
                     #{level3,jdbcType=DOUBLE},
                     #{level4,jdbcType=DOUBLE},
                     #{level5,jdbcType=DOUBLE},
                     #{imageDate,jdbcType=VARCHAR},
                     #{productCode1,jdbcType=VARCHAR},
                     #{productCode2,jdbcType=VARCHAR},
                     #{year,jdbcType=VARCHAR},
                     #{createdBy,jdbcType=VARCHAR}
                 )
        ]]>
    </insert>

    <insert id="InsertAspect">
        <![CDATA[
        INSERT INTO Aspect (
            zone ,
            region_name,
            North,
            Northeast ,
            East ,
            Southeast,
            South,
            Southwest ,
            West,
            Northwest,
            Image_date ,
            Product_code1 ,
            Product_code2,
            year1,
            created_by
        ) VALUES (
                     #{zone,jdbcType=VARCHAR},
                     #{zone,jdbcType=VARCHAR},
                     #{north,jdbcType=DOUBLE},
                     #{northeast,jdbcType=DOUBLE},
                     #{east,jdbcType=DOUBLE},
                     #{southeast,jdbcType=DOUBLE},
                     #{south,jdbcType=DOUBLE},
                     #{southwest,jdbcType=DOUBLE},
                     #{west,jdbcType=DOUBLE},
                     #{northwest,jdbcType=DOUBLE},
                     #{imageDate,jdbcType=VARCHAR},
                     #{productCode1,jdbcType=VARCHAR},
                     #{productCode2,jdbcType=VARCHAR},
                     #{year,jdbcType=VARCHAR},
                     #{createdBy,jdbcType=VARCHAR}
                 )
        ]]>
    </insert>

    <insert id="InsertSlope">
        <![CDATA[
        INSERT INTO Slope (
            zone ,
            region_name,
            level1,
            level2 ,
            level3 ,
            level4,
            level5,
            Image_date ,
            Product_code1 ,
            Product_code2,
            year1,
            created_by
        ) VALUES (
                     #{zone,jdbcType=VARCHAR},
                     #{zone,jdbcType=VARCHAR},
                     #{level1,jdbcType=DOUBLE},
                     #{level2,jdbcType=DOUBLE},
                     #{level3,jdbcType=DOUBLE},
                     #{level4,jdbcType=DOUBLE},
                     #{level5,jdbcType=DOUBLE},
                     #{imageDate,jdbcType=VARCHAR},
                     #{productCode1,jdbcType=VARCHAR},
                     #{productCode2,jdbcType=VARCHAR},
                     #{year,jdbcType=VARCHAR},
                     #{createdBy,jdbcType=VARCHAR}
                 )
        ]]>
    </insert>
</mapper>