<?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.com.ty.lift.batch.applet.dao.mapper.LiftDataMapper">

    <!-- 获取指定时间段内的电梯数据 -->
    <select id="getLiftDataList" parameterType="cn.com.ty.lift.batch.applet.dao.model.request.CommonRequest"
            resultType="cn.com.ty.lift.batch.applet.dao.model.LiftDataModel">
        select
            pclr.mt_company_id as mtCompanyId,
            pclr.create_date as connectTime,
            pclr.update_date as updateTime,
            pclr.lift_company_status as liftCompanyStatus,
            p.id as projectId,
            p.project_name as projectName,
            p.project_status as projectStatus,
            p.end_date as projectEndTime,
            plr.out_service_date as lostTime,
            r.id as regionId,
            r.area_name as regionName
        from
            platform_company_lift_relevance pclr
        left join
            project_lift_relevance plr
        on
            pclr.lift_id = plr.lift_id
        left join
            project p
        on
            plr.project_id = p.id
        left join
            region r
        on
            p.region_id = r.id
        where
            pclr.mt_company_id = #{mtCompanyId}
        <if test = "startTimeDateStr != null and startTimeDateStr != ''">
            and (
                pclr.create_date <![CDATA[ >= ]]> #{startTimeDateStr}
                or
                pclr.create_date is null)
        </if>
        <if test = "endTimeDateStr != null and endTimeDateStr != ''">
            and (
                pclr.create_date <![CDATA[ <= ]]> #{endTimeDateStr}
                or
                pclr.create_date is null)
        </if>
    </select>

</mapper>