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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_project_order a
        <where>
            <if test="param.projectOrderId != null">
                AND a.project_order_id = #{param.projectOrderId}
            </if>
          <if test="param.projectId != null">
            AND a.project_id = #{param.projectId}
          </if>
            <if test="param.equipmentName != null">
                AND a.equipment_name LIKE CONCAT('%', #{param.equipmentName}, '%')
            </if>
            <if test="param.equipmentModel != null">
                AND a.equipment_model LIKE CONCAT('%', #{param.equipmentModel}, '%')
            </if>
            <if test="param.equipmentNum != null">
                AND a.equipment_num = #{param.equipmentNum}
            </if>
            <if test="param.unit != null">
                AND a.unit LIKE CONCAT('%', #{param.unit}, '%')
            </if>
            <if test="param.startTime != null">
                AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
            </if>
            <if test="param.endTime != null">
                AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
            </if>
            <if test="param.year != null">
                AND a.year LIKE CONCAT('%', #{param.year}, '%')
            </if>
            <if test="param.documenter != null">
                AND a.documenter LIKE CONCAT('%', #{param.documenter}, '%')
            </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.TowerProjectOrder">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
