From a5e2b839742708fcac5e46990c26ff8df0b1bad8 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Fri, 16 Dec 2022 11:27:02 +0800 Subject: [PATCH] device4Search --- api/app/lib/schedule/alarms_push.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index b9c955b..6c4d851 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -902,7 +902,12 @@ module.exports = function (app, opts) { const device4Search = [...deviceIds] .map(id => "'" + id + "'") deviceSensorRes = await clickHouse.anxinyun.query(` - SELECT iota_device_id, sensor FROM t_device_sensor WHERE iota_device_id IN (${device4Search.join(',')}, '-1') + SELECT + iota_device_id, sensor + FROM t_device_sensor + WHERE iota_device_id + ${device4Search.length > 1 ? `IN (${device4Search.join(',')})` : `= ${device4Search[0]}`} + `).toPromise() } if (proDebug) {