<?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.zsElectric.boot.business.mapper.ThirdPartyEquipmentInfoMapper">

    <select id="selectEquipmentInfoPage" resultType="com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO">
        SELECT
            e.id,
            e.equipment_id,
            e.equipment_name,
            e.station_id,
            s.station_name,
            e.equipment_type,
            e.power,
            e.update_time,
            c.connector_id,
            c.connector_name,
            c.connector_type,
            c.voltage_upper_limits,
            c.voltage_lower_limits,
            c.current,
            c.park_no,
            c.national_standard
        FROM
            third_party_equipment_info e
        LEFT JOIN third_party_station_info s ON e.station_id = s.station_id
        LEFT JOIN third_party_connector_info c ON e.equipment_id = c.equipment_id
        <where>
            e.is_deleted = 0
            <if test="query.equipmentId != null and query.equipmentId != ''">
                AND e.equipment_id = #{query.equipmentId}
            </if>
            <if test="query.equipmentName != null and query.equipmentName != ''">
                AND e.equipment_name LIKE CONCAT('%', #{query.equipmentName}, '%')
            </if>
            <if test="query.stationId != null and query.stationId != ''">
                AND e.station_id = #{query.stationId}
            </if>
            <if test="query.stationName != null and query.stationName != ''">
                AND s.station_name LIKE CONCAT('%', #{query.stationName}, '%')
            </if>
            <if test="query.equipmentType != null and query.equipmentType != 0">
                AND e.equipment_type = #{query.equipmentType}
            </if>
            <if test="query.connectorType != null and query.connectorType != 0">
                AND c.connector_type = #{query.connectorType}
            </if>
            <if test="query.parkNo != null and query.parkNo != ''">
                AND c.park_no = #{query.parkNo}
            </if>
            <if test="query.nationalStandard != null and query.nationalStandard != 0">
                AND c.national_standard = #{query.nationalStandard}
            </if>
        </where>
        ORDER BY e.update_time DESC
    </select>

</mapper>
