<?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.yeejoin.equipmanage.mapper.EquipmentPointMapper">
    <select id="listBySearchMap" resultType="com.yeejoin.equipmanage.common.entity.EquipmentPoint">
        select
        a.id,
        a.name,
        a.code,
        a.equipment_id as fireEquipmentId,
        a.create_by as createBy,
        a.create_date as createDate,
        a.remark,
        a.type,
        a.value,
        a.unit,
        a.unit_name as unitName,
        a.org_code as orgCode,
        fd.name as alarmName,
        a.equipment_name as equipmentName,
        a.equipment_code as equipmentCode
        from
        wl_equipment_point as a
        left join wl_system_dic fd on fd.id = a.alarm_type
        <where>
            a.org_code = #{compCode}
            <if test="searchValue!=null and searchValue.trim() != ''">
                and (a.name like concat('%',#{searchValue},'%') or a.code like concat('%',#{searchValue},'%'))
            </if>
            <if test="type!=null and type.trim() != ''">
                and a.type = #{type}
            </if>
        </where>
        order by a.create_date desc
    </select>
</mapper>
