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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_equipment a
        <where>
            <if test="param.equipmentId != null">
                AND a.equipment_id = #{param.equipmentId}
            </if>
            <if test="param.name != null">
                AND a.name LIKE CONCAT('%', #{param.name}, '%')
            </if>
            <if test="param.model != null">
                AND a.model LIKE CONCAT('%', #{param.model}, '%')
            </if>
            <if test="param.equipmentNo != null">
                AND a.equipment_no LIKE CONCAT('%', #{param.equipmentNo}, '%')
            </if>
            <if test="param.factoryNo != null">
                AND a.factory_no LIKE CONCAT('%', #{param.factoryNo}, '%')
            </if>
            <if test="param.factoryDate != null">
                AND a.factory_date LIKE CONCAT('%', #{param.factoryDate}, '%')
            </if>
            <if test="param.manufactor != null">
                AND a.manufactor LIKE CONCAT('%', #{param.manufactor}, '%')
            </if>
            <if test="param.lifeYear != null">
                AND a.life_year LIKE CONCAT('%', #{param.lifeYear}, '%')
            </if>
            <if test="param.scrapDate != null">
                AND a.scrap_date LIKE CONCAT('%', #{param.scrapDate}, '%')
            </if>
            <if test="param.licenceNo != null">
                AND a.licence_no LIKE CONCAT('%', #{param.licenceNo}, '%')
            </if>
            <if test="param.company != null">
                AND a.company = #{param.company}
            </if>
            <if test="param.organization != null">
                AND a.organization = #{param.organization}
            </if>
            <if test="param.warehouse != null">
                AND a.warehouse = #{param.warehouse}
            </if>
            <if test="param.source != null">
                AND a.source LIKE CONCAT('%', #{param.source}, '%')
            </if>
            <if test="param.buyDate != null">
                AND a.buy_date LIKE CONCAT('%', #{param.buyDate}, '%')
            </if>
            <if test="param.currentLocation != null">
                AND a.current_location LIKE CONCAT('%', #{param.currentLocation}, '%')
            </if>
            <if test="param.designHeight != null">
                AND a.design_height LIKE CONCAT('%', #{param.designHeight}, '%')
            </if>
            <if test="param.height != null">
                AND a.height LIKE CONCAT('%', #{param.height}, '%')
            </if>
            <if test="param.ratedLoad != null">
                AND a.rated_load LIKE CONCAT('%', #{param.ratedLoad}, '%')
            </if>
            <if test="param.maxRatedLoad != null">
                AND a.max_rated_load LIKE CONCAT('%', #{param.maxRatedLoad}, '%')
            </if>
            <if test="param.files != null">
                AND a.files LIKE CONCAT('%', #{param.files}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </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>
            <if test="param.keywords != null">
              AND (
              a.name LIKE CONCAT('%', #{param.keywords}, '%')
              OR a.model LIKE CONCAT('%', #{param.keywords}, '%')
              OR a.equipment_no LIKE CONCAT('%', #{param.keywords}, '%')
              OR a.company LIKE CONCAT('%', #{param.keywords}, '%')
              )
            </if>
        </where>
    </sql>

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

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

</mapper>
