<?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.LandUseMapper">
    <resultMap id="RM_Seeding" type="com.ruoyi.system.domain_shate.LandUse">
        <result property="id" column="id"/>
        <result property="zone" column="zone"/>
        <result property="regionName" column="region_name"/>
        <result property="landUse" column="Land_use"/>
        <result property="area" column="area"/>
        <result property="total"  column="total"/>
        <result property="percent" column="percent"/>
        <result property="imageDate" column="Image_date"/>
        <result property="productCode1" column="Product_code1"/>
        <result property="productCode2" column="Product_code2"/>
        <result property="productCode3" column="Product_code3"/>
        <result property="createdBy" column="created_by"/>
        <result property="year" column="year1"/>

    </resultMap>

    <sql id="columns">
	    <![CDATA[
        ID,zone,region_name,land_use,year1,total,area,percent,Image_date,Product_code1,Product_code2,Product_code3,created_by
        ]]>
	</sql>

    <select id="sqlSeeding" resultMap="RM_Seeding">
        SELECT  <include refid="columns"/>  FROM  landuse
        where land_use IN <foreach collection="landUses" item="landUse" open="(" close=")" separator=",">#{landUse}</foreach>

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

    </select>

    <select id="sqlSeeding1" resultMap="RM_Seeding">
        SELECT  <include refid="columns"/>  FROM  landuse
        where 1=1
        <if test="zone!= null and zone !=''">

            AND zone = #{zone}
        </if>
        <if test="year!= null and year !=''">
            AND year1 = #{year}
        </if>
        ORDER BY   land_use
    </select>

    <select id="sqlYear" resultMap="RM_Seeding">
        SELECT  distinct year1,ZONE,region_name   FROM  landuse ORDER BY ZONE
    </select>

        <insert id="insertSeeding">
            <![CDATA[
            INSERT INTO landuse (
                zone ,
                region_name,
                Land_use,
                total,
                area ,
                percent ,
                Image_date ,
                Product_code1 ,
                Product_code2,
                Product_code3,
                year1,
                created_by
            ) VALUES (
                                     #{zone,jdbcType=VARCHAR},
                                     #{zone,jdbcType=VARCHAR},
                                     #{landUse,jdbcType=DOUBLE},
                                     #{total,jdbcType=DOUBLE},
                                     #{area,jdbcType=DOUBLE},
                                     #{percent,jdbcType=DOUBLE},
                                     #{imageDate,jdbcType=VARCHAR},
                                     #{productCode1,jdbcType=VARCHAR},
                                     #{productCode2,jdbcType=VARCHAR},
                                     #{productCode3,jdbcType=VARCHAR},
                                     #{year,jdbcType=VARCHAR},
                                     #{createdBy,jdbcType=VARCHAR}
                     )
            ]]>
        </insert>
</mapper>