|
|
@ -315,12 +315,12 @@ |
|
|
PARTITION BY device_id |
|
|
PARTITION BY device_id |
|
|
ORDER BY receive_ts DESC |
|
|
ORDER BY receive_ts DESC |
|
|
) AS rn |
|
|
) AS rn |
|
|
FROM alert_history |
|
|
FROM alert_history where alert_history.source_type = 1 |
|
|
) alert_history on alert_history.device_id = device_info.device_id |
|
|
) alert_history on alert_history.device_id = device_info.device_id AND alert_history.rn = 1 |
|
|
</when> |
|
|
</when> |
|
|
<otherwise> |
|
|
<otherwise> |
|
|
alert_history |
|
|
alert_history |
|
|
left join device_info on alert_history.device_id = device_info.device_id |
|
|
left join device_info on alert_history.device_id = device_info.device_id and alert_history.source_type = 1 |
|
|
</otherwise> |
|
|
</otherwise> |
|
|
</choose> |
|
|
</choose> |
|
|
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id |
|
|
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id |
|
|
@ -375,12 +375,12 @@ |
|
|
PARTITION BY device_id |
|
|
PARTITION BY device_id |
|
|
ORDER BY receive_ts DESC |
|
|
ORDER BY receive_ts DESC |
|
|
) AS rn |
|
|
) AS rn |
|
|
FROM alert_history |
|
|
FROM alert_history where alert_history.source_type = 1 |
|
|
) alert_history on alert_history.device_id = device_info.device_id |
|
|
) alert_history on alert_history.device_id = device_info.device_id AND alert_history.rn = 1 |
|
|
</when> |
|
|
</when> |
|
|
<otherwise> |
|
|
<otherwise> |
|
|
alert_history |
|
|
alert_history |
|
|
left join device_info on alert_history.device_id = device_info.device_id |
|
|
left join device_info on alert_history.device_id = device_info.device_id and alert_history.source_type = 1 |
|
|
</otherwise> |
|
|
</otherwise> |
|
|
</choose> |
|
|
</choose> |
|
|
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id |
|
|
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id |
|
|
|