<?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.modules.business.rtu.data.mapper.RtuDataRainMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="rtuRainDataResultMap" type="org.springblade.modules.business.rtu.data.entity.RtuDataRainEntity">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="rtu_code" property="rtuCode"/>
        <result column="tm" property="tm"/>
        <result column="drp" property="drp"/>

    </resultMap>


    <resultMap id="rtuRainDataVOResultMap" type="org.springblade.modules.business.rtu.data.vo.RtuDataRainVO">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="rtu_code" property="rtuCode"/>
        <result column="tm" property="tm"/>
        <result column="drp" property="drp"/>
        <result column="rtu_name" property="rtuName"/>
    </resultMap>


    <select id="selectPage" resultMap="rtuRainDataVOResultMap">
        SELECT
        n.*,
        p.rtu_name
        FROM
        data_att_st_prec_cache n
        LEFT JOIN  rtu_info p ON n.rtu_code = p.rtu_code

        WHERE
        n.is_deleted = 0
        <if test="rtuDataRainDTO.rtuName!=null ">
            and p.rtu_name LIKE concat(concat('%', #{rtuDataRainDTO.rtuName}), '%')
        </if>
        <if test="rtuDataRainDTO.orgId!=null">
            and p.org_id = #{rtuDataRainDTO.orgId}
        </if>
        <if test="rtuDataRainDTO.projectId!=null ">
            and p.project_id = #{rtuDataRainDTO.projectId}
        </if>

    </select>
</mapper>
