<?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.RtuDataGroundMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="rtuGroundDataResultMap" type="org.springblade.modules.business.rtu.data.entity.RtuDataGroundEntity">
        <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="vtavslm" property="vtavslm"/>
        <result column="srlslm" property="srlslm"/>
        <result column="slm10" property="slm10"/>
        <result column="slm20" property="slm20"/>
        <result column="slm30" property="slm30"/>
        <result column="slm40" property="slm40"/>
        <result column="slm60" property="slm60"/>
        <result column="slm80" property="slm80"/>
        <result column="slm100" property="slm100"/>

    </resultMap>


    <resultMap id="rtuGroundDataVOResultMap" type="org.springblade.modules.business.rtu.data.vo.RtuDataGroundVO">
        <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="vtavslm" property="vtavslm"/>
        <result column="srlslm" property="srlslm"/>
        <result column="rtu_name" property="rtuName"/>
        <result column="slm10" property="slm10"/>
        <result column="slm20" property="slm20"/>
        <result column="slm30" property="slm30"/>
        <result column="slm40" property="slm40"/>
        <result column="slm60" property="slm60"/>
        <result column="slm80" property="slm80"/>
        <result column="slm100" property="slm100"/>
    </resultMap>


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

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

    </select>
</mapper>
