<?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="cn.cecep.talroad.mapper.OdsElectricityElecPsEquipRelationTsAMapper">

    <select id="selectListByDeviceIdAndTime" resultType="cn.cecep.talroad.domain.analysis.SRaRealTimeAnalysisRun">
        SELECT
            srrtar.factory_id,
            srrtar.factory_name,
            srrtar.device_name,
            oeeperta.treatment_equip_id as deviceId,
            srrtar.device_type,
            srrtar.operation_status,
            srrtar.judgement_basis
        FROM
            ods_electricity_elec_ps_equip_relation_ts_a oeeperta
            LEFT JOIN s_ra_real_time_analysis_run srrtar ON srrtar.device_id = oeeperta.productor_equip_id
        WHERE
            srrtar.judgement_basis = '2'
            <if test="deviceIds != null and deviceIds.size() != 0">
                AND oeeperta.treatment_equip_id IN
                <foreach collection="deviceIds" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
                <if test="updateTime != null">
                    AND srrtar.update_time = #{updateTime}
                </if>
            </if>
    </select>
</mapper>
