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

    <!-- 获取指定时间段内的维保数据 -->
    <select id="getMaintenanceDataList" parameterType="cn.com.ty.lift.batch.applet.dao.model.request.CommonRequest"
            resultType="cn.com.ty.lift.batch.applet.dao.model.MaintenanceDataModel">
        select
            mp.mt_company_id as mtCompanyId,
            mp.project_id as projectId,
            mp.plan_date as planDate,
            mp.lift_id as liftId,
            mp.create_date as createDate,
            mp.work_date as finishDate,
            mp.count as count,
            plr.first_time as firstDate,
            p.project_name as projectName
        from
            maintenance_plan mp
        left join
            maintenance_record mr
        on
            mp.id = mr.mt_plan_id
        left join
            project_lift_relevance plr
        on
            mp.lift_id = plr.lift_id
        left join
            project p
        on
            mp.project_id = p.id
        where
            mp.plan_date <![CDATA[ >= ]]> #{startTimeDateStr}
        and
            mp.plan_date <![CDATA[ <= ]]> #{endTimeDateStr}
    </select>

</mapper>