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() } }) // 状态向前端页面推送