|
|
@ -310,18 +310,26 @@ async function getCmaeraUniqueConfig (ctx) { |
|
|
|
// TODO: 目前只获取 yingshi 的
|
|
|
|
|
|
|
|
const cameraRes = await sequelize.query(` |
|
|
|
SELECT DISTINCT("serial_no", "channel_no"), |
|
|
|
camera.id, |
|
|
|
"camera"."serial_no" AS "serialNo", |
|
|
|
"camera"."type" AS "type", |
|
|
|
"camera"."channel_no" AS "channelNo", |
|
|
|
"secretYingshi"."token" AS "yingshiToken" |
|
|
|
FROM "camera" AS "camera" |
|
|
|
LEFT OUTER JOIN "secret_yingshi" AS "secretYingshi" |
|
|
|
ON "camera"."yingshi_secret_id" = "secretYingshi"."id" |
|
|
|
WHERE "camera"."delete" = false |
|
|
|
AND "camera"."type" = 'yingshi' |
|
|
|
AND "camera"."recycle_time" IS NULL; |
|
|
|
SELECT DISTINCT ON ("serial_no", "channel_no") |
|
|
|
camera.id, |
|
|
|
"camera"."serial_no" AS "serialNo", |
|
|
|
"camera"."type" AS "type", |
|
|
|
"camera"."channel_no" AS "channelNo", |
|
|
|
"secretYingshi"."token" AS "yingshiToken", |
|
|
|
camera_status_offline_log."status" AS "status", |
|
|
|
camera_status_offline_log."time" AS "updateTime" |
|
|
|
FROM "camera" AS "camera" |
|
|
|
LEFT JOIN "secret_yingshi" AS "secretYingshi" |
|
|
|
ON "camera"."yingshi_secret_id" = "secretYingshi"."id" |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT camera_id, MAX(time) AS time FROM camera_status_offline_log GROUP BY camera_id |
|
|
|
) AS offlineLogMax |
|
|
|
ON offlineLogMax."camera_id" = "camera"."id" |
|
|
|
LEFT JOIN camera_status_offline_log |
|
|
|
ON camera_status_offline_log.time = offlineLogMax.time |
|
|
|
WHERE "camera"."delete" = false |
|
|
|
AND "camera"."type" = 'yingshi' |
|
|
|
AND "camera"."recycle_time" IS NULL; |
|
|
|
`)
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|