<?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="org.springblade.etl.mapper.EtlGroundDataMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="groundDataEntityResultMap" type="org.springblade.etl.entity.EtlGroundDataEntity">
        <result column="GUID" property="guid"/>
        <result column="ST_CODE" property="rtuCode"/>
        <result column="MEAS_DATE" property="tm"/>
        <result column="EXT_KEY" property="extKey"/>
        <result column="VERT_AVER_MOCO" property="vertAverMoco"/>
        <result column="SURF_MOCO" property="surfMoco"/>
        <result column="MOCO_10CM" property="moco10cm"/>
        <result column="MOCO_20CM" property="moco20cm"/>
        <result column="MOCO_30CM" property="moco30cm"/>
        <result column="MOCO_40CM" property="moco40cm"/>
        <result column="MOCO_50CM" property="moco50cm"/>
        <result column="MOCO_60CM" property="moco60cm"/>
        <result column="MOCO_80CM" property="moco80cm"/>
        <result column="MOCO_100CM" property="moco100cm"/>
        <result column="CROP_TYPE" property="cropType"/>
        <result column="CROP_GROW" property="cropGrow"/>
        <result column="CROP_WAT" property="cropWat"/>
        <result column="SOIL_MOCO_METH" property="soilMocoMeth"/>
        <result column="FROM_DATE" property="fromDate"/>
        <result column="TO_DATE" property="toDate"/>
    </resultMap>

    <select id="selectRtus" resultMap="groundDataEntityResultMap">
        SELECT
        d.ST_CODE
        FROM
        SL_ZHSL_NM_EXTRA.ATT_ST_SOMO d
        WHERE 1=1
        group by d.ST_CODE
    </select>

    <!--SL_ZHSL_NM_EXTRA.ATT_ST_SOMO d-->
    <select id="selectLastList" resultMap="groundDataEntityResultMap">
        SELECT * FROM
        ( SELECT
        d.*
        FROM
        SL_ZHSL_NM_EXTRA.ATT_ST_SOMO d
        WHERE 1=1
        <if test="entity.rtuCode!=null">
            and d.ST_CODE = #{entity.rtuCode}
        </if>
        <if test="entity.tm!=null">
            and d.MEAS_DATE > #{entity.tm}
        </if>
        order by d.MEAS_DATE desc )
        WHERE ROWNUM &lt;= 1
    </select>

    <select id="selectNewList" resultMap="groundDataEntityResultMap">
        SELECT
        d.*
        FROM
        SL_ZHSL_NM_EXTRA.ATT_ST_SOMO d
        WHERE 1=1
        <if test="entity.rtuCode!=null">
            and d.ST_CODE = #{entity.rtuCode}
        </if>
        <if test="entity.tm!=null">
            and d.MEAS_DATE > #{entity.tm}
        </if>
        order by d.MEAS_DATE
    </select>
</mapper>
