From 9b5c2b2d281436b806682088e0bfe98a75c41244 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 13 Oct 2022 10:54:08 +0800 Subject: [PATCH] =?UTF-8?q?getCmaeraUniqueConfig=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/app/lib/controllers/camera/index.js | 32 ++++++++++++------- .../api/app/lib/schedule/freshYingshiMsg.js | 3 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js index 4fdb38c..a5d8c73 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js @@ -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; diff --git a/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js b/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js index da46997..ccf2fb9 100644 --- a/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js +++ b/code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js @@ -81,7 +81,8 @@ module.exports = function (app, opts) { // 在离线状态更新 await models.GbCamera.update(storageD, { where: { - id: existD.id + id: existD.id, + updateTime: moment().format() } }) // 状态向前端页面推送