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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_project a
        <where>
            <if test="param.projectId != null">
                AND a.project_id = #{param.projectId}
            </if>
            <if test="param.projectName != null">
                AND a.project_name LIKE CONCAT('%', #{param.projectName}, '%')
            </if>
            <if test="param.companyName != null">
                AND a.company_name LIKE CONCAT('%', #{param.companyName}, '%')
            </if>
            <if test="param.customerName != null">
                AND a.customer_name LIKE CONCAT('%', #{param.customerName}, '%')
            </if>
            <if test="param.projectRegion != null">
                AND a.project_region LIKE CONCAT('%', #{param.projectRegion}, '%')
            </if>
            <if test="param.projectAddress != null">
                AND a.project_address LIKE CONCAT('%', #{param.projectAddress}, '%')
            </if>
            <if test="param.longitude != null">
                AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
            </if>
            <if test="param.latitude != null">
                AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
            </if>
            <if test="param.superviseNo != null">
                AND a.supervise_no LIKE CONCAT('%', #{param.superviseNo}, '%')
            </if>
            <if test="param.licenceNo != null">
                AND a.licence_no LIKE CONCAT('%', #{param.licenceNo}, '%')
            </if>
            <if test="param.securityStatus != null">
                AND a.security_status LIKE CONCAT('%', #{param.securityStatus}, '%')
            </if>
            <if test="param.competentDepartment != null">
                AND a.competent_department LIKE CONCAT('%', #{param.competentDepartment}, '%')
            </if>
            <if test="param.dismantlingCompany != null">
                AND a.dismantling_company LIKE CONCAT('%', #{param.dismantlingCompany}, '%')
            </if>
            <if test="param.truckCraneSpecs != null">
                AND a.truck_crane_specs LIKE CONCAT('%', #{param.truckCraneSpecs}, '%')
            </if>
            <if test="param.contract != null">
                AND a.contract LIKE CONCAT('%', #{param.contract}, '%')
            </if>
            <if test="param.director != null">
                AND a.director = #{param.director}
            </if>
            <if test="param.projectDirector != null">
                AND a.project_director LIKE CONCAT('%', #{param.projectDirector}, '%')
            </if>
            <if test="param.projectStatus != null">
                AND a.project_status LIKE CONCAT('%', #{param.projectStatus}, '%')
            </if>
            <if test="param.salesman != null">
                AND a.salesman LIKE CONCAT('%', #{param.salesman}, '%')
            </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.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </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.TowerProject">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
