<?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.SoilFactorMapper">
    <resultMap id="RM_Desert" type="com.ruoyi.system.domain_shate.SoilDesertification">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <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="year" column="year1"/>
        <result property="imageDate" column="Image_date"/>
        <result property="productCode1" column="Product_code1"/>
        <result property="productCode2" column="Product_code2"/>
        <result property="createdBy" column="created_by"/>
    </resultMap>


    <resultMap id="RM_Moisture" type="com.ruoyi.system.domain_shate.SoilMoisture">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <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"/>
        <result property="craeteTime" column="created_time"/>
    </resultMap>

    <resultMap id="RM_Salin" type="com.ruoyi.system.domain_shate.SoilSalinization">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <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"/>
        <result property="craeteTime" column="created_time"/>
    </resultMap>

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


    <select id="sqlDesert" resultMap="RM_Desert">
        SELECT  <include refid="columns"/>  FROM  desertification
        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_Desert">
        SELECT  distinct year1,ZONE  FROM  desertification
    </select>

    <select id="sqlMoisture" resultMap="RM_Moisture">
        SELECT  <include refid="columns"/>  FROM  moisture
        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_Moisture">
        SELECT  distinct year1,ZONE  FROM  moisture
    </select>

    <select id="sqlSalin" resultMap="RM_Salin">
        SELECT  <include refid="columns"/>  FROM  salinization
        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_Salin">
        SELECT  distinct year1,ZONE  FROM  salinization
    </select>

    <insert id="InsertDesert">
        <![CDATA[
        INSERT INTO desertification (
            zone ,
            level1,
            level2 ,
            level3 ,
            level4,
            level5,
            Image_date ,
            Product_code1 ,
            Product_code2,
            year1,
            created_by
        ) VALUES (
                     #{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="InsertMoisture">
        <![CDATA[
        INSERT INTO moisture (
            zone ,
            level1,
            level2 ,
            level3 ,
            level4,
            level5,
            Image_date ,
            Product_code1 ,
            Product_code2,
            year1,
            created_by
        ) VALUES (
                     #{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="InsertSalin">
        <![CDATA[
        INSERT INTO salinization (
            zone ,
            level1,
            level2 ,
            level3 ,
            level4,
            level5,
            Image_date ,
            Product_code1 ,
            Product_code2,
            year1,
            created_by
        ) VALUES (
                     #{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>