<?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="cn.iocoder.yudao.module.system.dal.mysql.biz.ElderlyDailyCleanDisinfectRecordMapper">

    <!--
        带楼栋和楼层信息的分页查询
    -->
    <select id="selectPageWithBuildInfo" resultType="cn.iocoder.yudao.module.system.controller.admin.biz.vo.dailycleandisinfectrecord.ElderlyDailyCleanDisinfectRecordRespVO">
        SELECT
            edcdr.*,
            ob.build_name AS buildName,
            obf.floor_name AS floorName
        FROM elderly_daily_clean_disinfect_record edcdr
        LEFT JOIN org_build ob ON edcdr.build_id = ob.id
        LEFT JOIN org_build_floor obf ON edcdr.floor_id = obf.id AND obf.build_id = ob.id
        WHERE 1=1
        <if test="reqVO.buildId != null">
            AND edcdr.build_id = #{reqVO.buildId}
        </if>
        <if test="reqVO.floorId != null">
            AND edcdr.floor_id = #{reqVO.floorId}
        </if>
        <if test="reqVO.assessMonth != null and reqVO.assessMonth.length >= 1">
            AND edcdr.assess_month &gt;= #{reqVO.assessMonth[0]}
        </if>
        <if test="reqVO.assessMonth != null and reqVO.assessMonth.length == 2">
            AND edcdr.assess_month &lt; #{reqVO.assessMonth[1]}
        </if>
        ORDER BY edcdr.assess_month DESC, edcdr.id DESC
    </select>

</mapper>
