Browse Source

getCmaeraUniqueConfig 增加状态和更新时间

dev_trial
巴林闲侠 2 years ago
parent
commit
9b5c2b2d28
  1. 32
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  2. 3
      code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js

32
code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js

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

3
code/VideoAccess-VCMP/api/app/lib/schedule/freshYingshiMsg.js

@ -81,7 +81,8 @@ module.exports = function (app, opts) {
// 在离线状态更新 // 在离线状态更新
await models.GbCamera.update(storageD, { await models.GbCamera.update(storageD, {
where: { where: {
id: existD.id id: existD.id,
updateTime: moment().format()
} }
}) })
// 状态向前端页面推送 // 状态向前端页面推送

Loading…
Cancel
Save