Browse Source

获取序列号+通道号唯一的全部摄像头

dev_trial
巴林闲侠 2 years ago
parent
commit
dd8f6f9528
  1. 3
      code/VideoAccess-VCMP/api/.vscode/launch.json
  2. 35
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  3. 15
      code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js
  4. 30
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js
  5. 3
      code/VideoAccess-VCMP/api/app/lib/routes/camera/index.js
  6. 1
      code/VideoAccess-VCMP/api/config.js
  7. 2
      code/VideoAccess-VCMP/api/sequelize-automate.config.js
  8. 12
      code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql

3
code/VideoAccess-VCMP/api/.vscode/launch.json

@ -15,7 +15,8 @@
"args": [ "args": [
"-p 4000", "-p 4000",
"-f http://localhost:4000", "-f http://localhost:4000",
"-g postgres://postgres:123@10.8.30.32:5432/video_access", // "-g postgres://postgres:123@10.8.30.32:5432/video_access",
"-g postgres://postgres:123@10.8.30.166:5432/video_access-dev",
"--redisHost 10.8.30.112", "--redisHost 10.8.30.112",
"--redisPort 6379", "--redisPort 6379",
"--axyApiUrl http://127.0.0.1:4100", "--axyApiUrl http://127.0.0.1:4100",

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

@ -301,6 +301,40 @@ async function getCameraListAll (ctx) {
} }
} }
async function getCmaeraUniqueConfig (ctx) {
// 为 李玉 python 摄像头状态查询的摄像头列表查询
// 获取所有已配置的序列号+通道号唯一的摄像头
try {
const { models } = ctx.fs.dc;
const sequelize = ctx.fs.dc.orm;
// 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;
`)
ctx.status = 200;
ctx.body = cameraRes[0]
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function banned (ctx) { async function banned (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
@ -587,6 +621,7 @@ module.exports = {
getCameraProject, getCameraProject,
getCamera, getCamera,
getCameraListAll, getCameraListAll,
getCmaeraUniqueConfig,
detail, detail,
banned, banned,
del, del,

15
code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js

@ -4,11 +4,12 @@ const moment = require('moment');
async function record (ctx) { async function record (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { statusCode, description = '', cameraId, platform = 'yingshi' } = ctx.request.body; const { statusCode, description = '', cameraId, platform = 'yingshi', serialNo, channelNo } = ctx.request.body;
let statusRes = await models.CameraStatus.findOne({ let statusRes = await models.CameraStatus.findOne({
where: { where: {
status: statusCode status: statusCode,
platform,
} }
}) })
let alarmRes = null; let alarmRes = null;
@ -25,7 +26,10 @@ async function record (ctx) {
statusId: statusRes.id, statusId: statusRes.id,
description, description,
cameraId, cameraId,
confirm: null confirm: null,
serialNo,
channelNo,
platform,
} }
}) })
} }
@ -34,11 +38,14 @@ async function record (ctx) {
updateTime: moment().format() updateTime: moment().format()
}) })
} else { } else {
await models.CameraStatusAlarm.create({ alarmRes = await models.CameraStatusAlarm.create({
statusId: statusRes.id, statusId: statusRes.id,
description, description,
createTime: moment().format(), createTime: moment().format(),
cameraId, cameraId,
serialNo,
channelNo,
platform,
}) })
} }

30
code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js

@ -73,18 +73,32 @@ module.exports = dc => {
field: "update_time", field: "update_time",
autoIncrement: false autoIncrement: false
}, },
cameraId: { serialNo: {
type: DataTypes.INTEGER, type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "序列号",
primaryKey: false,
field: "serial_no",
autoIncrement: false
},
channelNo: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "通道号",
primaryKey: false,
field: "channel_no",
autoIncrement: false
},
platform: {
type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
primaryKey: false, primaryKey: false,
field: "camera_id", field: "platform",
autoIncrement: false, autoIncrement: false
references: {
key: "id",
model: "camera"
}
} }
}, { }, {
tableName: "camera_status_alarm", tableName: "camera_status_alarm",

3
code/VideoAccess-VCMP/api/app/lib/routes/camera/index.js

@ -73,4 +73,7 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['POST/camera/remark'] = { content: '编辑摄像头备注', visible: false }; app.fs.api.logAttr['POST/camera/remark'] = { content: '编辑摄像头备注', visible: false };
router.post('/camera/remark', camera.remark); router.post('/camera/remark', camera.remark);
app.fs.api.logAttr['GET/camera/unique/all'] = { content: '获取全部摄像头,序列号+通道号唯一', visible: false };
router.get('/camera/unique/all', camera.getCmaeraUniqueConfig);
}; };

1
code/VideoAccess-VCMP/api/config.js

@ -95,6 +95,7 @@ const product = {
{ p: '/camera', o: 'GET' }, // 暂时滴 { p: '/camera', o: 'GET' }, // 暂时滴
{ p: '/application/check', o: 'GET' }, // 暂时滴 { p: '/application/check', o: 'GET' }, // 暂时滴
{ p: '/status/alarm', o: 'POST' }, { p: '/status/alarm', o: 'POST' },
{ p: '/camera/unique/all', o: 'GET' },
], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由
redis: { redis: {
host: IOTA_REDIS_SERVER_HOST, host: IOTA_REDIS_SERVER_HOST,

2
code/VideoAccess-VCMP/api/sequelize-automate.config.js

@ -26,7 +26,7 @@ module.exports = {
dir: './app/lib/models', // 指定输出 models 文件的目录 dir: './app/lib/models', // 指定输出 models 文件的目录
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义 typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir` emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
tables: ['camera_status_alarm',], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 tables: ['camera_status_alarm_camera',], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面

12
code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql

@ -7,13 +7,13 @@ create table if not exists camera_status_alarm
confirm_time timestamp with time zone, confirm_time timestamp with time zone,
create_time timestamp with time zone, create_time timestamp with time zone,
update_time timestamp with time zone, update_time timestamp with time zone,
camera_id integer, serial_no varchar(64),
channel_no varchar(64),
platform varchar(32),
constraint camera_status_alarm_pk constraint camera_status_alarm_pk
primary key (id), primary key (id),
constraint camera_status_alarm_camera_status_id_fk constraint camera_status_alarm_camera_status_id_fk
foreign key (status_id) references camera_status, foreign key (status_id) references camera_status
constraint camera_status_alarm_camera_id_fk
foreign key (camera_id) references camera
); );
comment on column camera_status_alarm.description is '描述'; comment on column camera_status_alarm.description is '描述';
@ -24,6 +24,10 @@ comment on column camera_status_alarm.create_time is '生成时间';
comment on column camera_status_alarm.update_time is '更新时间'; comment on column camera_status_alarm.update_time is '更新时间';
comment on column camera_status_alarm.serial_no is '序列号';
comment on column camera_status_alarm.channel_no is '通道号';
create unique index if not exists camera_status_alarm_id_uindex create unique index if not exists camera_status_alarm_id_uindex
on camera_status_alarm (id); on camera_status_alarm (id);

Loading…
Cancel
Save