<?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="com.gxwebsoft.tower.mapper.TowerRentRecordMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_rent_record a
        <where>
            <if test="param.rentRecordId != null">
                AND a.rent_record_id = #{param.rentRecordId}
            </if>
            <if test="param.projectId != null">
                AND a.project_id = #{param.projectId}
            </if>
            <if test="param.contractNo != null">
                AND a.contract_no LIKE CONCAT('%', #{param.contractNo}, '%')
            </if>
            <if test="param.equipmentId != null">
                AND a.equipment_id = #{param.equipmentId}
            </if>
            <if test="param.startDate != null">
                AND a.start_date LIKE CONCAT('%', #{param.startDate}, '%')
            </if>
            <if test="param.stopDate != null">
                AND a.stop_date LIKE CONCAT('%', #{param.stopDate}, '%')
            </if>
            <if test="param.checkDate != null">
                AND a.check_date LIKE CONCAT('%', #{param.checkDate}, '%')
            </if>
            <if test="param.reportStopDate != null">
                AND a.report_stop_date LIKE CONCAT('%', #{param.reportStopDate}, '%')
            </if>
            <if test="param.reportStopType != null">
                AND a.report_stop_type LIKE CONCAT('%', #{param.reportStopType}, '%')
            </if>
            <if test="param.restoreDate != null">
                AND a.restore_date LIKE CONCAT('%', #{param.restoreDate}, '%')
            </if>
            <if test="param.reportMonitorNo != null">
                AND a.report_monitor_no LIKE CONCAT('%', #{param.reportMonitorNo}, '%')
            </if>
            <if test="param.companyId != null">
                AND a.company_id = #{param.companyId}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.tower.entity.TowerRentRecord">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.tower.entity.TowerRentRecord">
        <include refid="selectSql"></include>
    </select>

</mapper>
