Browse Source

获取推送配置路由改为 push_list

dev_trial
巴林闲侠 3 years ago
parent
commit
24334393d1
  1. 57
      code/VideoAccess-VCMP/api/app/lib/controllers/status/alarm.js
  2. 15
      code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js
  3. 4
      code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js
  4. 32
      code/VideoAccess-VCMP/api/app/lib/controllers/vender/index.js
  5. 96
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_alarm.js
  6. 7
      code/VideoAccess-VCMP/api/app/lib/routes/index.js
  7. 9
      code/VideoAccess-VCMP/api/app/lib/routes/status/index.js
  8. 2
      code/VideoAccess-VCMP/api/app/lib/routes/vender/index.js
  9. 1
      code/VideoAccess-VCMP/api/config.js
  10. 2
      code/VideoAccess-VCMP/api/sequelize-automate.config.js
  11. 29
      code/VideoAccess-VCMP/script/1.3.3/schema/1.create_camera_status_alarm.sql
  12. 2
      code/VideoAccess-VCMP/web/client/src/layout/index.jsx
  13. 1658
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx
  14. 1182
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx
  15. 2
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js

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

@ -0,0 +1,57 @@
'use strict';
const moment = require('moment');
async function record (ctx) {
try {
const { models } = ctx.fs.dc;
const { statusCode, description = '', cameraId, platform = 'yingshi' } = ctx.request.body;
let statusRes = await models.CameraStatus.findOne({
where: {
status: statusCode
}
})
let alarmRes = null;
if (!statusRes) {
statusRes = await models.CameraStatus.create({
platform: platform,
status: statusCode,
describe: description,
forbidden: false,
})
} else {
alarmRes = await models.CameraStatusAlarm.findOne({
where: {
statusId: statusRes.id,
description,
cameraId,
confirm: null
}
})
}
if (alarmRes) {
await models.CameraStatusAlarm.update({
updateTime: moment().format()
})
} else {
await models.CameraStatusAlarm.create({
statusId: statusRes.id,
description,
createTime: moment().format(),
cameraId,
})
}
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
module.exports = {
record,
};

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

@ -264,6 +264,20 @@ async function statusCheck (ctx) {
} }
} }
async function statusRecord (ctx) {
try {
const models = ctx.fs.dc.models;
ctx.status = 20;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
module.exports = { module.exports = {
get, get,
getSimpleAll, getSimpleAll,
@ -271,4 +285,5 @@ module.exports = {
paraphraseCustom, paraphraseCustom,
resolveEdit, resolveEdit,
statusCheck, statusCheck,
statusRecord,
}; };

4
code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js

@ -119,7 +119,7 @@ async function edit (ctx) {
} }
} }
async function get (ctx) { async function getStatusPushList (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api const { userId, token } = ctx.fs.api
@ -397,5 +397,5 @@ async function pushLog (ctx) {
module.exports = { module.exports = {
edit, get, banned, del, copy, pushLog edit, getStatusPushList, banned, del, copy, pushLog
}; };

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

@ -1,23 +1,23 @@
'use strict'; 'use strict';
async function get (ctx) { async function getVenderList (ctx) {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
try { try {
const res = await models.Vender.findAll({ const res = await models.Vender.findAll({
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
] ]
}) })
ctx.status = 200; ctx.status = 200;
ctx.body = res ctx.body = res
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = {} ctx.body = {}
} }
} }
module.exports = { module.exports = {
get, getVenderList,
}; };

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

@ -0,0 +1,96 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusAlarm = sequelize.define("cameraStatusAlarm", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_alarm_id_uindex"
},
statusId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "status_id",
autoIncrement: false,
references: {
key: "id",
model: "cameraStatus"
}
},
description: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "描述",
primaryKey: false,
field: "description",
autoIncrement: false
},
confirm: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "确认信息",
primaryKey: false,
field: "confirm",
autoIncrement: false
},
confirmTime: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "confirm_time",
autoIncrement: false
},
createTime: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: "生成时间",
primaryKey: false,
field: "create_time",
autoIncrement: false
},
updateTime: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: "更新时间",
primaryKey: false,
field: "update_time",
autoIncrement: false
},
cameraId: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "camera_id",
autoIncrement: false,
references: {
key: "id",
model: "camera"
}
}
}, {
tableName: "camera_status_alarm",
comment: "",
indexes: []
});
dc.models.CameraStatusAlarm = CameraStatusAlarm;
return CameraStatusAlarm;
};

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

@ -7,8 +7,13 @@ module.exports = function (app, router, opts) {
fs.readdirSync(__dirname).forEach((filename) => { fs.readdirSync(__dirname).forEach((filename) => {
if (filename.indexOf('.') !== 0 && fs.lstatSync(path.join(__dirname, filename)).isDirectory()) { if (filename.indexOf('.') !== 0 && fs.lstatSync(path.join(__dirname, filename)).isDirectory()) {
fs.readdirSync(path.join(__dirname, filename)).forEach((api) => { fs.readdirSync(path.join(__dirname, filename)).forEach((api) => {
console.log('加载路由文件:' + filename + '/' + api);
if (api.indexOf('.') == 0 || api.indexOf('.js') == -1) return; if (api.indexOf('.') == 0 || api.indexOf('.js') == -1) return;
require(`./${filename}/${api}`)(app, router, opts); try {
require(`./${filename}/${api}`)(app, router, opts);
} catch (e) {
console.error(e);
}
}); });
} }
}); });

9
code/VideoAccess-VCMP/api/app/lib/routes/status/index.js

@ -2,6 +2,7 @@
const status = require('../../controllers/status'); const status = require('../../controllers/status');
const push = require('../../controllers/status/push'); const push = require('../../controllers/status/push');
const alarm = require('../../controllers/status/alarm');
module.exports = function (app, router, opts) { module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/status'] = { content: '获取状态码', visible: false }; app.fs.api.logAttr['GET/status'] = { content: '获取状态码', visible: false };
@ -26,8 +27,8 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['PUT/status/push'] = { content: '编辑推送配置', visible: false }; app.fs.api.logAttr['PUT/status/push'] = { content: '编辑推送配置', visible: false };
router.put('/status/push', push.edit); router.put('/status/push', push.edit);
app.fs.api.logAttr['GET/status/push'] = { content: '获取推送配置', visible: false }; app.fs.api.logAttr['GET/status/push_list'] = { content: '获取推送配置', visible: false };
router.get('/status/push', push.get); router.get('/status/push_list', push.getStatusPushList);
app.fs.api.logAttr['PUT/status/push/banned'] = { content: '禁用推送配置', visible: false }; app.fs.api.logAttr['PUT/status/push/banned'] = { content: '禁用推送配置', visible: false };
router.put('/status/push/banned', push.banned); router.put('/status/push/banned', push.banned);
@ -41,4 +42,8 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/status/push/:configId/detail'] = { content: '获取推送记录', visible: false }; app.fs.api.logAttr['GET/status/push/:configId/detail'] = { content: '获取推送记录', visible: false };
router.get('/status/push/:configId/log', push.pushLog); router.get('/status/push/:configId/log', push.pushLog);
// 信鸽推送 END // 信鸽推送 END
// 状态告警
app.fs.api.logAttr['POST/status/alarm'] = { content: '保存或更新告警信息', visible: false };
router.post('/status/alarm', alarm.record);
}; };

2
code/VideoAccess-VCMP/api/app/lib/routes/vender/index.js

@ -4,5 +4,5 @@ const vender = require('../../controllers/vender');
module.exports = function (app, router, opts) { module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/vender'] = { content: '获取设备厂商', visible: false }; app.fs.api.logAttr['GET/vender'] = { content: '获取设备厂商', visible: false };
router.get('/vender', vender.get); router.get('/vender', vender.getVenderList);
}; };

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

@ -94,6 +94,7 @@ const product = {
exclude: [ exclude: [
{ p: '/camera', o: 'GET' }, // 暂时滴 { p: '/camera', o: 'GET' }, // 暂时滴
{ p: '/application/check', o: 'GET' }, // 暂时滴 { p: '/application/check', o: 'GET' }, // 暂时滴
{ p: '/status/alarm', o: 'POST' },
], // 不做认证的路由,也可以使用 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: ['mirror',], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 tables: ['camera_status_alarm',], // 指定生成哪些表的 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_',] ,长度较长的 前缀放前面

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

@ -0,0 +1,29 @@
create table if not exists camera_status_alarm
(
id serial not null,
status_id integer not null,
description varchar(1024),
confirm varchar(1024),
confirm_time timestamp with time zone,
create_time timestamp with time zone,
update_time timestamp with time zone,
camera_id integer,
constraint camera_status_alarm_pk
primary key (id),
constraint camera_status_alarm_camera_status_id_fk
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.confirm is '确认信息';
comment on column camera_status_alarm.create_time is '生成时间';
comment on column camera_status_alarm.update_time is '更新时间';
create unique index if not exists camera_status_alarm_id_uindex
on camera_status_alarm (id);

2
code/VideoAccess-VCMP/web/client/src/layout/index.jsx

@ -202,7 +202,7 @@ const Root = props => {
} }
// setMicroAppWaiting(false) // setMicroAppWaiting(false)
if (props.location.pathname == '/video_play_status') { if (props.location && props.location.pathname == '/video_play_status') {
setAuthCrossLoading(false) setAuthCrossLoading(false)
setMicroAppWaiting(false) setMicroAppWaiting(false)
} }

1658
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx

File diff suppressed because it is too large

1182
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx

File diff suppressed because it is too large

2
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -54,7 +54,7 @@ export const ApiTable = {
postStatusCustom: 'status/custom',//自定义状态码释义 postStatusCustom: 'status/custom',//自定义状态码释义
getStatusSimpleAll: 'status/simple_all',//获取全部状态码简略信息 getStatusSimpleAll: 'status/simple_all',//获取全部状态码简略信息
getCameraListAll: 'camera/listAll',//获取所有摄像头信息 getCameraListAll: 'camera/listAll',//获取所有摄像头信息
getStatusPush: 'status/push',//获取推送配置 getStatusPush: 'status/push_list',//获取推送配置
putSasdtatusPush: 'status/push',//编辑推送配置 putSasdtatusPush: 'status/push',//编辑推送配置
delPush: 'status/push/{configId}',//删除推送配置 delPush: 'status/push/{configId}',//删除推送配置
putPushBanned: 'status/push/banned',//禁用推送配置 putPushBanned: 'status/push/banned',//禁用推送配置

Loading…
Cancel
Save