Compare commits
55 Commits
master
...
release_0.
Author | SHA1 | Date |
---|---|---|
deartibers | 6fc20ce0f7 | 2 years ago |
巴林闲侠 | 1fcdd18c62 | 2 years ago |
巴林闲侠 | ea528ba8d2 | 2 years ago |
巴林闲侠 | 41a7689b62 | 2 years ago |
巴林闲侠 | 590ba7e7b7 | 2 years ago |
巴林闲侠 | 5ed9ad0f76 | 2 years ago |
巴林闲侠 | 9794a829d5 | 2 years ago |
巴林闲侠 | 80eb3bc978 | 2 years ago |
巴林闲侠 | 68277930eb | 2 years ago |
巴林闲侠 | 31e3597074 | 2 years ago |
巴林闲侠 | cbe3c821d4 | 2 years ago |
巴林闲侠 | 211e4832ad | 2 years ago |
巴林闲侠 | e7b2ed2223 | 2 years ago |
deartibers | ebecc75750 | 2 years ago |
deartibers | 52fbdc60b1 | 2 years ago |
巴林闲侠 | 11e81efaca | 2 years ago |
巴林闲侠 | 9566025669 | 2 years ago |
deartibers | 12a73f7d5a | 2 years ago |
巴林闲侠 | 4dad078802 | 2 years ago |
巴林闲侠 | 5fffd15729 | 2 years ago |
巴林闲侠 | 6b86b35409 | 2 years ago |
巴林闲侠 | 63cccc1f6f | 2 years ago |
巴林闲侠 | b0512c5deb | 2 years ago |
巴林闲侠 | b3cfc828a5 | 2 years ago |
巴林闲侠 | 37ef6eb430 | 2 years ago |
巴林闲侠 | 02e3f7393b | 2 years ago |
巴林闲侠 | 3871adf4bf | 2 years ago |
巴林闲侠 | 2111b014e2 | 2 years ago |
巴林闲侠 | 9f41ef4445 | 2 years ago |
巴林闲侠 | 225b6b5ec2 | 2 years ago |
巴林闲侠 | fddf05c742 | 2 years ago |
巴林闲侠 | 14f8d00ea5 | 2 years ago |
巴林闲侠 | bfba015319 | 2 years ago |
deartibers | de3eba495e | 2 years ago |
deartibers | 7e43ef5d7f | 2 years ago |
wenlele | f033f4cc6b | 2 years ago |
wenlele | 156643b093 | 2 years ago |
巴林闲侠 | cfc316897f | 2 years ago |
巴林闲侠 | a38d71ec5a | 2 years ago |
巴林闲侠 | 7f8a7f83ff | 2 years ago |
deartibers | ccfda4ed32 | 2 years ago |
deartibers | fa84a546c6 | 2 years ago |
巴林闲侠 | f7f9b309f0 | 2 years ago |
巴林闲侠 | 4ae13f8ff6 | 2 years ago |
deartibers | 8596e5c6a0 | 2 years ago |
deartibers | f5bda27f5e | 2 years ago |
巴林闲侠 | b9b0b28645 | 2 years ago |
wenlele | 981b25f0c2 | 2 years ago |
wenlele | 22daa473aa | 2 years ago |
deartibers | 80676e5ed2 | 2 years ago |
巴林闲侠 | 538bc90235 | 2 years ago |
巴林闲侠 | 431a3350f8 | 2 years ago |
deartibers | 72c12478dd | 2 years ago |
巴林闲侠 | 8728e7f2ab | 2 years ago |
巴林闲侠 | 4d47205fa6 | 2 years ago |
@ -0,0 +1,130 @@ |
|||
'use strict'; |
|||
|
|||
const moment = require('moment') |
|||
|
|||
async function inspection (ctx) { |
|||
// 巡查
|
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { projectAppId, screenshot = [], } = ctx.request.body |
|||
|
|||
const now = moment().format() |
|||
const storageData = screenshot.map(s => { |
|||
return { |
|||
projectAppId, |
|||
screenshot: s.url, |
|||
createTime: now, |
|||
description: s.description, |
|||
} |
|||
}) |
|||
|
|||
await models.AppInspection.bulkCreate(storageData) |
|||
|
|||
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 |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function notedInspection (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { inspectionId } = ctx.request.body |
|||
const { userId } = ctx.fs.api |
|||
|
|||
await models.AppInspection.update({ |
|||
notedPepUserId: userId, |
|||
notedTime: moment().format() |
|||
}, { |
|||
where: { |
|||
id: inspectionId |
|||
} |
|||
}) |
|||
|
|||
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 |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function apiError (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { projectAppId, alarmContent, router, statusCode } = ctx.request.body |
|||
const now = moment().format() |
|||
|
|||
let storageData = { |
|||
projectAppId, alarmContent, router, statusCode |
|||
} |
|||
const existRes = await models.AppAlarm.findOne({ |
|||
where: { |
|||
projectAppId, alarmContent, router, statusCode, |
|||
confirm: null |
|||
} |
|||
}) |
|||
if (existRes) { |
|||
await models.AppAlarm.update({ |
|||
updateTime: now |
|||
}, { |
|||
where: { |
|||
id: existRes.id |
|||
} |
|||
}) |
|||
} else { |
|||
const existCount = await models.AppAlarm.count({ |
|||
where: { |
|||
|
|||
} |
|||
}) |
|||
storageData.serialNumber = 'WEB' + (existCount < 9 ? '0' + (existCount + 1) : existCount) |
|||
storageData.createTime = now |
|||
await models.AppAlarm.create(storageData) |
|||
} |
|||
|
|||
ctx.status = 200; |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function confirmApiError (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { confirm, appAlarmId } = ctx.request.body |
|||
|
|||
await models.AppAlarm.update({ |
|||
confirm, |
|||
}, { |
|||
where: { |
|||
id: appAlarmId |
|||
} |
|||
}) |
|||
|
|||
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 = { |
|||
inspection, |
|||
notedInspection, |
|||
apiError, |
|||
confirmApiError, |
|||
}; |
@ -0,0 +1,112 @@ |
|||
'use strict'; |
|||
const Hex = require('crypto-js/enc-hex'); |
|||
const MD5 = require('crypto-js/md5'); |
|||
const moment = require('moment'); |
|||
const uuid = require('uuid'); |
|||
|
|||
async function login (ctx, next) { |
|||
// const transaction = await ctx.fs.dc.orm.transaction();
|
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const params = ctx.request.body; |
|||
|
|||
const emisLoginRes = await ctx.app.fs.emisRequest.post('login', { |
|||
data: params |
|||
}) |
|||
|
|||
if (!emisLoginRes) { |
|||
throw "无此用户,请使用正确的登录信息" |
|||
} else { |
|||
const pomsRegisterRes = await models.User.findOne({ |
|||
where: { |
|||
pepUserId: emisLoginRes.id, |
|||
$or: { |
|||
deleted: false, |
|||
role: { $contains: ['admin'] } |
|||
} |
|||
} |
|||
}) |
|||
if (!pomsRegisterRes) { |
|||
throw '你还不是飞尚运维中台成员,请联系管理员添加权限' |
|||
} else if ( |
|||
pomsRegisterRes.disable && (!pomsRegisterRes.role || !pomsRegisterRes.role.includes('admin')) |
|||
) { |
|||
throw '当前账号已禁用' |
|||
} |
|||
emisLoginRes.pomsUserInfo = pomsRegisterRes.dataValues |
|||
|
|||
let userUpdateData = { |
|||
lastInTime: moment().format(), |
|||
inTimes: pomsRegisterRes.inTimes + 1, |
|||
lastInAddress: '' |
|||
} |
|||
try { |
|||
// 获取ip转为地点并记录
|
|||
let ip = |
|||
// '117.90.39.49' ||
|
|||
ctx.ip |
|||
console.log(`当前登录用户IP:${ip}`); |
|||
if (ip && /^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$/.test(ip)) { |
|||
const ipLocationRes = await ctx.app.fs.godRequest.post('ip', { |
|||
query: { |
|||
ip, |
|||
} |
|||
}) |
|||
if (ipLocationRes) { |
|||
userUpdateData.lastInAddress = ipLocationRes.province + ipLocationRes.city |
|||
} |
|||
} |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`IP GET, error: ${error}`); |
|||
} |
|||
|
|||
|
|||
await models.User.update(userUpdateData, { |
|||
where: { |
|||
id: emisLoginRes.id |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = emisLoginRes; |
|||
} |
|||
// await transaction.commit();
|
|||
} catch (error) { |
|||
// await transaction.rollback();
|
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
let message = typeof error == 'string' ? error |
|||
: error.response.body.message || "登录失败" |
|||
if (message == '账号或密码错误') { |
|||
message = '无此用户,请使用正确的登录信息' |
|||
} |
|||
|
|||
ctx.body = { |
|||
message: message |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function logout (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const params = ctx.request.body; |
|||
|
|||
await ctx.app.fs.emisRequest.put('logout', { |
|||
data: params |
|||
}) |
|||
|
|||
ctx.status = 204; |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
login, |
|||
logout, |
|||
}; |
@ -0,0 +1,229 @@ |
|||
'use strict'; |
|||
const moment = require('moment') |
|||
|
|||
async function allDeps (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { redis } = ctx.app |
|||
|
|||
let depRes = await redis.get('allDepartments') |
|||
if (depRes) { |
|||
depRes = JSON.parse(depRes) |
|||
depRes = depRes.departments |
|||
} |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = depRes || [] |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
async function editUser (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { pepUserId, role = [], correlationProject = [] } = ctx.request.body |
|||
|
|||
const existUserRes = await models.User.findOne({ |
|||
where: { |
|||
pepUserId |
|||
} |
|||
}) |
|||
if (existUserRes && !existUserRes.deleted && !pepUserId) { |
|||
// 新增已存在未删除
|
|||
throw '人员账号已添加' |
|||
} |
|||
|
|||
let storageData = { |
|||
pepUserId, |
|||
role, |
|||
correlationProject, |
|||
updateTime: moment().format() |
|||
} |
|||
if (existUserRes) { |
|||
// 存在且传递id 或者 不传id也存在
|
|||
// 修改 update
|
|||
storageData.deleted = false |
|||
storageData.role = [...new Set([...existUserRes.role, ...role])] |
|||
if ( |
|||
storageData.role.includes('admin') |
|||
) { |
|||
storageData.disabled = false |
|||
} |
|||
await models.User.update(storageData, { |
|||
where: { |
|||
pepUserId |
|||
} |
|||
}) |
|||
} else { |
|||
// 新增
|
|||
await models.User.create(storageData) |
|||
} |
|||
|
|||
ctx.status = 200 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
async function putUser (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { pomsUserId } = ctx.params |
|||
const { disabled = undefined, deleted = undefined } = ctx.request.body |
|||
const existUserRes = await models.User.findOne({ |
|||
where: { |
|||
id: pomsUserId |
|||
} |
|||
}) |
|||
|
|||
if (existUserRes && existUserRes.role.includes('admin') && disabled) { |
|||
throw '成员不能既是管理员又是普通成员' |
|||
} |
|||
|
|||
const updateData = { |
|||
disabled, |
|||
deleted, |
|||
} |
|||
for (let k in updateData) { |
|||
if (updateData[k] == undefined) { |
|||
delete updateData[k] |
|||
} |
|||
} |
|||
|
|||
await models.User.update(updateData, { |
|||
where: { |
|||
id: pomsUserId |
|||
} |
|||
}) |
|||
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 |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function delAdmin (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { pomsUserId } = ctx.params |
|||
|
|||
const existUserRes = await models.User.findOne({ |
|||
where: { |
|||
id: pomsUserId |
|||
} |
|||
}) |
|||
if (existUserRes) { |
|||
let updateValues = existUserRes.dataValues |
|||
let adminIndex = updateValues.role.findIndex(r => r == 'admin') |
|||
if (adminIndex > -1) { |
|||
updateValues.role.splice(adminIndex, 1) |
|||
} |
|||
await models.User.update(updateValues, { |
|||
where: { |
|||
id: pomsUserId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
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 |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function user (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { clickHouse } = ctx.app.fs |
|||
const { role, limit, page, } = ctx.query |
|||
|
|||
const excludeField = ['lastInTime', 'inTimes', 'onlineDuration', 'lastInAddress', 'deleted', 'updateTime'] |
|||
|
|||
let findOption = { |
|||
attributes: { |
|||
exclude: excludeField, |
|||
}, |
|||
where: { |
|||
deleted: false, |
|||
$not: { |
|||
role: { $contained: ['SuperAdmin', 'admin'] } |
|||
} |
|||
}, |
|||
order: [['updateTime', 'DESC']] |
|||
} |
|||
if (role) { |
|||
findOption.where.role = { $contains: [role] } |
|||
} |
|||
if (limit) { |
|||
findOption.limit = limit |
|||
} |
|||
if (page && limit) { |
|||
findOption.offset = page * limit |
|||
} |
|||
|
|||
const userRes = await models.User.findAndCountAll(findOption) |
|||
|
|||
const adminRes = await models.User.findAll({ |
|||
where: { |
|||
role: { $contains: ['admin'] } |
|||
}, |
|||
attributes: { |
|||
exclude: excludeField, |
|||
}, |
|||
order: [['updateTime', 'DESC']] |
|||
}) |
|||
|
|||
let userIds = new Set() |
|||
for (let u of userRes.rows.concat(adminRes)) { |
|||
userIds.add(u.pepUserId) |
|||
} |
|||
let userPepRes = await clickHouse.pepEmis.query(`SELECT user.id AS id, "user"."name" AS name, department.name AS depName, department.id AS depId FROM department_user LEFT JOIN user ON department_user.user=user.id LEFT JOIN department ON department.id=department_user.department WHERE user.id IN (${[...userIds].join(',')}) AND department.delete=false`).toPromise() |
|||
|
|||
for (let u of userRes.rows.concat(adminRes)) { |
|||
const corUsers = userPepRes.filter(up => up.id == u.pepUserId) |
|||
u.dataValues.name = corUsers[0].name |
|||
u.dataValues.departments = corUsers.map(cu => { |
|||
return { |
|||
name: cu.depName, |
|||
id: cu.depId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
ctx.status = 200 |
|||
ctx.body = { |
|||
admin: adminRes, |
|||
users: userRes |
|||
} |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
allDeps, |
|||
editUser, |
|||
putUser, |
|||
delAdmin, |
|||
user, |
|||
}; |
@ -0,0 +1,23 @@ |
|||
'use strict'; |
|||
|
|||
async function bindAnxin2pep (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { clickHouse } = ctx.app.fs |
|||
const { name } = ctx.request.body |
|||
|
|||
|
|||
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 = { |
|||
bindAnxin2pep |
|||
}; |
@ -0,0 +1,26 @@ |
|||
'use strict'; |
|||
|
|||
async function appList (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
|
|||
const appRes = await models.ProjectApp.findAll({ |
|||
attributes: { |
|||
exclude: ['projectId'] |
|||
} |
|||
}) |
|||
ctx.status = 200; |
|||
ctx.body = appRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
module.exports = { |
|||
appList, |
|||
}; |
@ -0,0 +1,115 @@ |
|||
'use strict'; |
|||
const moment = require('moment') |
|||
|
|||
async function list (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { keyword, alarmType, state, } = ctx.request.body |
|||
|
|||
let findOption = { |
|||
where: { |
|||
|
|||
} |
|||
} |
|||
|
|||
if (keyword) { |
|||
findOption.where.$or = [ |
|||
{ |
|||
name: { $like: `%${keyword}%` } |
|||
}, |
|||
] |
|||
} |
|||
if (alarmType) { |
|||
findOption.where.alarmType = { $contains: [alarmType] } |
|||
} |
|||
if (state) { |
|||
if (state == 'enable') { |
|||
findOption.where.disable = false |
|||
} else if (state == 'disable') { |
|||
findOption.where.disable = true |
|||
} else if (state == 'overtime') { |
|||
|
|||
} |
|||
} |
|||
|
|||
const listRes = await models.AlarmPushConfig.findAndCountAll(findOption) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = listRes |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function edit (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { userId } = ctx.fs.api |
|||
const { pushId, name, pepProjectId = [], alarmType = [], receiverPepUserId = [], timeType = [], disable } = ctx.request.body |
|||
|
|||
let storageData = { |
|||
name, pepProjectId, alarmType, receiverPepUserId, timeType, disable |
|||
} |
|||
if (pushId) { |
|||
await models.AlarmPushConfig.update(storageData, { |
|||
where: { |
|||
id: pushId |
|||
} |
|||
}) |
|||
} else { |
|||
storageData.createTime = moment().format() |
|||
storageData.createUserId = userId |
|||
await models.AlarmPushConfig.create(storageData) |
|||
} |
|||
|
|||
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 |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function state (ctx) { |
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { pushId } = ctx.params |
|||
const { disable = undefined, del = undefined, } = ctx.request.body |
|||
|
|||
if (del) { |
|||
await models.AlarmPushConfig.destroy({ |
|||
where: { |
|||
id: pushId |
|||
} |
|||
}) |
|||
} else { |
|||
await models.AlarmPushConfig.update({ |
|||
disable, |
|||
}, { |
|||
where: { |
|||
id: pushId |
|||
} |
|||
}) |
|||
} |
|||
|
|||
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 = { |
|||
list, edit, state |
|||
}; |
@ -0,0 +1,65 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ActionLog = sequelize.define("actionLog", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "action_log_id_uindex" |
|||
}, |
|||
userId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "user_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "user" |
|||
} |
|||
}, |
|||
time: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "time", |
|||
autoIncrement: false |
|||
}, |
|||
action: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "动态内容", |
|||
primaryKey: false, |
|||
field: "action", |
|||
autoIncrement: false |
|||
}, |
|||
expandParams: { |
|||
type: DataTypes.JSONB, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "expand_params", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "action_log", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ActionLog = ActionLog; |
|||
return ActionLog; |
|||
}; |
@ -0,0 +1,106 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const AppAlarm = sequelize.define("appAlarm", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "app_alarm_id_uindex" |
|||
}, |
|||
serialNumber: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "自定义编号", |
|||
primaryKey: false, |
|||
field: "serial_number", |
|||
autoIncrement: false |
|||
}, |
|||
projectAppId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "对应的项目id", |
|||
primaryKey: false, |
|||
field: "project_app_id", |
|||
autoIncrement: false |
|||
}, |
|||
appDomain: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "应用域名", |
|||
primaryKey: false, |
|||
field: "app_domain", |
|||
autoIncrement: false |
|||
}, |
|||
alarmContent: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "告警信息", |
|||
primaryKey: false, |
|||
field: "alarm_content", |
|||
autoIncrement: false |
|||
}, |
|||
createTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "create_time", |
|||
autoIncrement: false |
|||
}, |
|||
updateTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "update_time", |
|||
autoIncrement: false |
|||
}, |
|||
confirm: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "确认信息", |
|||
primaryKey: false, |
|||
field: "confirm", |
|||
autoIncrement: false |
|||
}, |
|||
router: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "路由", |
|||
primaryKey: false, |
|||
field: "router", |
|||
autoIncrement: false |
|||
}, |
|||
statusCode: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "状态码", |
|||
primaryKey: false, |
|||
field: "status_code", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "app_alarm", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.AppAlarm = AppAlarm; |
|||
return AppAlarm; |
|||
}; |
@ -0,0 +1,83 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const AppInspection = sequelize.define("appInspection", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "app_inspection_id_uindex" |
|||
}, |
|||
projectAppId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "project_app_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "projectApp" |
|||
} |
|||
}, |
|||
createTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "create_time", |
|||
autoIncrement: false |
|||
}, |
|||
screenshot: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "截图存储路径", |
|||
primaryKey: false, |
|||
field: "screenshot", |
|||
autoIncrement: false |
|||
}, |
|||
notedPepUserId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "核验人员", |
|||
primaryKey: false, |
|||
field: "noted_pep_user_id", |
|||
autoIncrement: false |
|||
}, |
|||
notedTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "noted_time", |
|||
autoIncrement: false |
|||
}, |
|||
description: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "description", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "app_inspection", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.AppInspection = AppInspection; |
|||
return AppInspection; |
|||
}; |
@ -1,35 +0,0 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const AxProject = sequelize.define("axProject", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: false, |
|||
unique: "ax_project_id_uindex" |
|||
}, |
|||
name: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "name", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "ax_project", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
|
|||
dc.models.AxProject = AxProject; |
|||
return AxProject; |
|||
}; |
@ -0,0 +1,56 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ProjectApp = sequelize.define("projectApp", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "project_app_id_uindex" |
|||
}, |
|||
name: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "name", |
|||
autoIncrement: false |
|||
}, |
|||
url: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "url", |
|||
autoIncrement: false |
|||
}, |
|||
projectId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "project_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "projectCorrelation" |
|||
} |
|||
} |
|||
}, { |
|||
tableName: "project_app", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ProjectApp = ProjectApp; |
|||
return ProjectApp; |
|||
}; |
@ -0,0 +1,70 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ProjectCorrelation = sequelize.define("projectCorrelation", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "project_correlation_id_uindex" |
|||
}, |
|||
anxinProjectId: { |
|||
type: DataTypes.ARRAY(DataTypes.INTEGER), |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "anxin_project_id", |
|||
autoIncrement: false |
|||
}, |
|||
pepProjectId: { |
|||
type: DataTypes.ARRAY(DataTypes.INTEGER), |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "项目管理的项目id", |
|||
primaryKey: false, |
|||
field: "pep_project_id", |
|||
autoIncrement: false |
|||
}, |
|||
createTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "create_time", |
|||
autoIncrement: false |
|||
}, |
|||
createUser: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "create_user", |
|||
autoIncrement: false |
|||
}, |
|||
name: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "name", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "project_correlation", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ProjectCorrelation = ProjectCorrelation; |
|||
return ProjectCorrelation; |
|||
}; |
@ -0,0 +1,47 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const QuickLink = sequelize.define("quickLink", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "quick_link_id_uindex" |
|||
}, |
|||
userId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "user_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "user" |
|||
} |
|||
}, |
|||
link: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "link", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "quick_link", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.QuickLink = QuickLink; |
|||
return QuickLink; |
|||
}; |
@ -0,0 +1,115 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const User = sequelize.define("user", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "user_id_uindex" |
|||
}, |
|||
pepUserId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "项企对应用户id", |
|||
primaryKey: false, |
|||
field: "pep_user_id", |
|||
autoIncrement: false |
|||
}, |
|||
role: { |
|||
type: DataTypes.ARRAY(DataTypes.STRING), |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "角色 也对应权限 admin 管理员 / all 全部角色 / data_analyst 数据分析 / after_sale 售后运维 / resource_manage 资源管理 / customer_service 客户服务", |
|||
primaryKey: false, |
|||
field: "role", |
|||
autoIncrement: false |
|||
}, |
|||
correlationProject: { |
|||
type: DataTypes.ARRAY(DataTypes.INTEGER), |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "关联的项目管理的项目id", |
|||
primaryKey: false, |
|||
field: "correlation_project", |
|||
autoIncrement: false |
|||
}, |
|||
lastInTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "last_in_time", |
|||
autoIncrement: false |
|||
}, |
|||
inTimes: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: "0", |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "in_times", |
|||
autoIncrement: false |
|||
}, |
|||
onlineDuration: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: "0", |
|||
comment: "在线时长 单位 s", |
|||
primaryKey: false, |
|||
field: "online_duration", |
|||
autoIncrement: false |
|||
}, |
|||
lastInAddress: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "上次登录地点", |
|||
primaryKey: false, |
|||
field: "last_in_address", |
|||
autoIncrement: false |
|||
}, |
|||
disabled: { |
|||
type: DataTypes.BOOLEAN, |
|||
allowNull: false, |
|||
defaultValue: false, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "disabled", |
|||
autoIncrement: false |
|||
}, |
|||
deleted: { |
|||
type: DataTypes.BOOLEAN, |
|||
allowNull: false, |
|||
defaultValue: false, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "deleted", |
|||
autoIncrement: false |
|||
}, |
|||
updateTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: sequelize.fn('now'), |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "update_time", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "user", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.User = User; |
|||
return User; |
|||
}; |
@ -0,0 +1,20 @@ |
|||
|
|||
|
|||
'use strict'; |
|||
|
|||
const application = require('../../controllers/alarm/app'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
// 应用告警
|
|||
app.fs.api.logAttr['POST/alarm/application/inspection'] = { content: '保存应用巡检信息', visible: true }; |
|||
router.post('/alarm/application/inspection', application.inspection); |
|||
|
|||
app.fs.api.logAttr['PUT/alarm/application/noted'] = { content: '保存检验状态', visible: true }; |
|||
router.put('/alarm/application/noted', application.notedInspection); |
|||
|
|||
app.fs.api.logAttr['POST/alarm/application/api'] = { content: '保存应用接口错误信息', visible: true }; |
|||
router.post('/alarm/application/api', application.apiError); |
|||
|
|||
app.fs.api.logAttr['POST/alarm/application/api_confirm'] = { content: '确认应用接口错误信息', visible: true }; |
|||
router.post('/alarm/application/api_confirm', application.confirmApiError); |
|||
}; |
@ -0,0 +1,11 @@ |
|||
'use strict'; |
|||
|
|||
const auth = require('../../controllers/auth'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['POST/login'] = { content: '登录', visible: true }; |
|||
router.post('/login', auth.login); |
|||
|
|||
app.fs.api.logAttr['PUT/logout'] = { content: '登出', visible: false }; |
|||
router.put('/logout', auth.logout); |
|||
}; |
@ -0,0 +1,20 @@ |
|||
'use strict'; |
|||
|
|||
const organization = require('../../controllers/organization'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['GET/organization/deps'] = { content: '获取全部部门及其下用户', visible: true }; |
|||
router.get('/organization/deps', organization.allDeps); |
|||
|
|||
app.fs.api.logAttr['POST/organization/user'] = { content: '编辑成员', visible: true }; |
|||
router.post('/organization/user', organization.editUser); |
|||
|
|||
app.fs.api.logAttr['PUT/organization/user/:pomsUserId'] = { content: '修改成员状态', visible: true }; |
|||
router.put('/organization/user/:pomsUserId', organization.putUser); |
|||
|
|||
app.fs.api.logAttr['DEL/organization/admin/:pomsUserId'] = { content: '删除管理员', visible: true }; |
|||
router.delete('/organization/admin/:pomsUserId', organization.delAdmin); |
|||
|
|||
app.fs.api.logAttr['GET/organization/user'] = { content: '获取成员列表', visible: true }; |
|||
router.get('/organization/user', organization.user); |
|||
}; |
@ -0,0 +1,13 @@ |
|||
'use strict'; |
|||
|
|||
const project = require('../../controllers/project'); |
|||
const projectBind = require('../../controllers/project/bind') |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['GET/project/app_list'] = { content: '获取应用列表', visible: true }; |
|||
router.get('/project/app_list', project.appList); |
|||
|
|||
app.fs.api.logAttr['POST/project/bind'] = { content: '绑定安心云、项目管理项目', visible: true }; |
|||
router.post('/project/bind', projectBind.bindAnxin2pep); |
|||
|
|||
}; |
@ -0,0 +1,14 @@ |
|||
'use strict'; |
|||
|
|||
const push = require('../../controllers/push/config'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['GET/push'] = { content: '获取推送配置列表', visible: true }; |
|||
router.get('/push', push.list); |
|||
|
|||
app.fs.api.logAttr['POST/push'] = { content: '新增/编辑推送配置', visible: true }; |
|||
router.get('/push', push.edit); |
|||
|
|||
app.fs.api.logAttr['PUT/push/:pushId'] = { content: '更改推送配置状态(禁用或删除)', visible: true }; |
|||
router.put('/push/:pushId', push.state); |
|||
}; |
@ -0,0 +1,36 @@ |
|||
'use strict'; |
|||
|
|||
const fs = require('fs'); |
|||
const nodeSchedule = require('node-schedule'); |
|||
|
|||
// 将定时任务汇集未来可根据需要选取操作
|
|||
module.exports = async function (app, opts) { |
|||
|
|||
const scheduleInit = ({ |
|||
interval, immediate, proRun, |
|||
}, callback) => { |
|||
if (proRun && opts.dev) { |
|||
return; |
|||
} |
|||
const j = nodeSchedule.scheduleJob(interval, callback); |
|||
if (immediate && (!proRun || (proRun && !opts.dev))) { |
|||
setTimeout(callback, 0) |
|||
} |
|||
return j; |
|||
} |
|||
|
|||
app.fs.scheduleInit = scheduleInit |
|||
|
|||
fs.readdirSync(__dirname).forEach((filename) => { |
|||
if (!['index.js'].some(f => filename == f)) { |
|||
const scheduleList = require(`./${filename}`)(app, opts) |
|||
for (let k of Object.keys(scheduleList)) { |
|||
console.info(`定时任务 ${k} 启动`); |
|||
} |
|||
app.fs.schedule = { |
|||
...app.fs.schedule, |
|||
...scheduleList, |
|||
} |
|||
} |
|||
}); |
|||
}; |
@ -0,0 +1,31 @@ |
|||
'use strict'; |
|||
const { ClickHouse } = require('clickhouse'); |
|||
|
|||
function factory (app, opts) { |
|||
if (opts.clickHouse) { |
|||
try { |
|||
app.fs.clickHouse = {} |
|||
const { url, port, db = [] } = opts.clickHouse |
|||
for (let d of db) { |
|||
if (d.name && d.db) { |
|||
app.fs.clickHouse[d.name] = new ClickHouse({ |
|||
url: url, |
|||
port: port, |
|||
debug: opts.dev, |
|||
format: "json", |
|||
config: { |
|||
database: d.db, |
|||
}, |
|||
}) |
|||
} else { |
|||
throw 'opts.clickHouse 参数错误!' |
|||
} |
|||
} |
|||
} catch (error) { |
|||
console.error(error) |
|||
process.exit(-1); |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = factory; |
@ -0,0 +1,23 @@ |
|||
'use strict'; |
|||
const mqtt = require('mqtt'); |
|||
|
|||
module.exports = async function factory (app, opts) { |
|||
// console.info(`mqtt connecting ${opts.mqtt.mqttVideoServer}`);
|
|||
|
|||
// const client = mqtt.connect(opts.mqtt.mqttVideoServer);
|
|||
|
|||
// client.on('connect', function () {
|
|||
// console.info(`mqtt connect success ${opts.mqtt.mqttVideoServer}`);
|
|||
// client.subscribe('topic/test', { qos: 0 });//订阅主题为test的消息
|
|||
// })
|
|||
// client.on('error', function (e) {
|
|||
// console.error(`mqtt connect failed ${opts.mqtt.mqttVideoServer}`);
|
|||
// app.fs.logger.error('info', '[FS-AUTH-MQTT]', `mqtt connect failed ${opts.mqtt.mqttVideoServer}`);
|
|||
// })
|
|||
|
|||
// client.on('message', async (top, message) => {
|
|||
|
|||
// });
|
|||
|
|||
// app.mqttVideoServer = client
|
|||
} |
@ -1,40 +0,0 @@ |
|||
'use strict'; |
|||
const mqtt = require('mqtt'); |
|||
|
|||
module.exports = async function factory (app, opts) { |
|||
console.info(`mqtt connecting ${opts.mqtt.mqttVideoServer}`); |
|||
|
|||
const client = mqtt.connect(opts.mqtt.mqttVideoServer); |
|||
|
|||
client.on('connect', function () { |
|||
console.info(`mqtt connect success ${opts.mqtt.mqttVideoServer}`); |
|||
client.subscribe('topic/test', { qos: 0 });//订阅主题为test的消息
|
|||
}) |
|||
client.on('error', function (e) { |
|||
console.error(`mqtt connect failed ${opts.mqtt.mqttVideoServer}`); |
|||
app.fs.logger.error('info', '[FS-AUTH-MQTT]', `mqtt connect failed ${opts.mqtt.mqttVideoServer}`); |
|||
}) |
|||
|
|||
client.on('message', async (top, message) => { |
|||
let msgStr = message.toString(); |
|||
let msg = JSON.parse(msgStr.replace(/\\/g, '')); |
|||
if (msg.id && msg.online) { |
|||
const { cameraStatePush } = app.fs.utils |
|||
const { models } = app.fs.dc |
|||
const gbCameraRes = await models.GbCamera.findOne({ |
|||
where: { |
|||
id: msg.id |
|||
} |
|||
}) |
|||
if (gbCameraRes) { |
|||
cameraStatePush({ |
|||
gbId: msg.id, |
|||
online: msg.online, |
|||
ipctype: gbCameraRes.ipctype, |
|||
}) |
|||
} |
|||
} |
|||
}); |
|||
|
|||
app.mqttVideoServer = client |
|||
} |
@ -1,33 +1,40 @@ |
|||
'use strict'; |
|||
const moment = require('moment') |
|||
|
|||
module.exports = async function factory (app, opts) { |
|||
|
|||
app.socket.on('connection', async (socket) => { |
|||
console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已连接:' + socket.id); |
|||
console.info('WEB_SOCKET token:' + socket.handshake.query.token + ' 已连接:id ' + socket.id + ' 时间:' + moment(socket.handshake.time).format()); |
|||
|
|||
socket.on('disconnecting', async (reason) => { |
|||
console.info('WEB_SOCKET ' + socket.handshake.query.token + ' 已断开连接:' + reason); |
|||
const connectSeconds = moment().diff(moment(socket.handshake.time), 'seconds') |
|||
|
|||
console.info('WEB_SOCKET token:' + socket.handshake.query.token + ' 已断开连接:' + reason + ' 连接时长:' + connectSeconds + 's'); |
|||
|
|||
const { models } = app.fs.dc |
|||
await models.User.increment({ |
|||
onlineDuration: connectSeconds |
|||
}, { |
|||
where: { |
|||
id: socket.handshake.query.pomsUserId |
|||
} |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
// 使用测试 保持链接
|
|||
setInterval(async () => { |
|||
const { connected } = app.socket.sockets |
|||
|
|||
const roomId = 'ROOM_' + Math.random() |
|||
// if (connected) {
|
|||
// for (let c in connected) {
|
|||
// connected[c].join(roomId)
|
|||
// }
|
|||
// app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, })
|
|||
// }
|
|||
|
|||
app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', }) |
|||
|
|||
// app.socket.emit('CAMERA_ONLINE', {
|
|||
// ipctype: 'yingshi',
|
|||
// online: Math.random() > 0.5 ? 'ON' : 'OFF',
|
|||
// gbId: Math.floor(Math.random() * 100),
|
|||
// name: 'cameraName'
|
|||
// })
|
|||
}, 3000) |
|||
// setInterval(async () => {
|
|||
// const { connected } = app.socket.sockets
|
|||
|
|||
// const roomId = 'ROOM_' + Math.random()
|
|||
// // if (connected) {
|
|||
// // for (let c in connected) {
|
|||
// // connected[c].join(roomId)
|
|||
// // }
|
|||
// // app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, })
|
|||
// // }
|
|||
|
|||
// app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', })
|
|||
|
|||
// }, 3000)
|
|||
} |
|||
|
@ -1,3 +0,0 @@ |
|||
{ |
|||
"editor.wordWrap": "on" |
|||
} |
@ -1,543 +0,0 @@ |
|||
/* |
|||
Navicat Premium Data Transfer |
|||
|
|||
Source Server : 10.8.30.32 |
|||
Source Server Type : PostgreSQL |
|||
Source Server Version : 90515 |
|||
Source Host : 10.8.30.32:5432 |
|||
Source Catalog : video_access |
|||
Source Schema : public |
|||
|
|||
Target Server Type : PostgreSQL |
|||
Target Server Version : 90515 |
|||
File Encoding : 65001 |
|||
|
|||
Date: 06/07/2022 11:45:25 |
|||
*/ |
|||
|
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for camera_ability_bind_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."camera_ability_bind_id_seq"; |
|||
CREATE SEQUENCE "public"."camera_ability_bind_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for camera_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."camera_id_seq"; |
|||
CREATE SEQUENCE "public"."camera_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for camera_remark_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."camera_remark_id_seq"; |
|||
CREATE SEQUENCE "public"."camera_remark_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for gbCamera_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."gbCamera_id_seq"; |
|||
CREATE SEQUENCE "public"."gbCamera_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for gb_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."gb_id_seq"; |
|||
CREATE SEQUENCE "public"."gb_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for nvr_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."nvr_id_seq"; |
|||
CREATE SEQUENCE "public"."nvr_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for secret_yingshi_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."secret_yingshi_id_seq"; |
|||
CREATE SEQUENCE "public"."secret_yingshi_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for t_upload_comm_http_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."t_upload_comm_http_id_seq"; |
|||
CREATE SEQUENCE "public"."t_upload_comm_http_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Sequence structure for vender_id_seq |
|||
-- ---------------------------- |
|||
DROP SEQUENCE IF EXISTS "public"."vender_id_seq"; |
|||
CREATE SEQUENCE "public"."vender_id_seq" |
|||
INCREMENT 1 |
|||
MINVALUE 1 |
|||
MAXVALUE 9223372036854775807 |
|||
START 1 |
|||
CACHE 1; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for ax_project |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."ax_project"; |
|||
CREATE TABLE "public"."ax_project" ( |
|||
"id" int4 NOT NULL, |
|||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL |
|||
) |
|||
; |
|||
COMMENT ON TABLE "public"."ax_project" IS '安心云项目副表,主要用于和camera等进行联合查询 |
|||
在安心云进行摄像头绑定的时候进行同步'; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of ax_project |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."ax_project" VALUES (1, '安心云项目'); |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for camera |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."camera"; |
|||
CREATE TABLE "public"."camera" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('camera_id_seq'::regclass), |
|||
"type" varchar(16) COLLATE "pg_catalog"."default" NOT NULL, |
|||
"name" varchar(128) COLLATE "pg_catalog"."default", |
|||
"channel_name" varchar(64) COLLATE "pg_catalog"."default", |
|||
"external_domain" varchar(64) COLLATE "pg_catalog"."default", |
|||
"rtmp" varchar(1024) COLLATE "pg_catalog"."default", |
|||
"serial_no" varchar(128) COLLATE "pg_catalog"."default", |
|||
"cloud_control" bool, |
|||
"high_definition" bool, |
|||
"voice" bool, |
|||
"memory_card" varchar(32) COLLATE "pg_catalog"."default", |
|||
"vender_id" int4, |
|||
"cascade_type" varchar(32) COLLATE "pg_catalog"."default", |
|||
"sip" varchar(1024) COLLATE "pg_catalog"."default", |
|||
"longitude" numeric(16,12), |
|||
"latitude" numeric(16,12), |
|||
"forbidden" bool NOT NULL DEFAULT false, |
|||
"create_time" timestamptz(6) NOT NULL, |
|||
"recycle_time" timestamptz(6), |
|||
"delete" bool NOT NULL DEFAULT false, |
|||
"create_user_id" int4 NOT NULL, |
|||
"nvr_id" int4, |
|||
"model" varchar(128) COLLATE "pg_catalog"."default", |
|||
"kind_id" int4, |
|||
"yingshi_secret_id" int4, |
|||
"gb_id" int4, |
|||
"top_serial_no" varchar(128) COLLATE "pg_catalog"."default" |
|||
) |
|||
; |
|||
COMMENT ON COLUMN "public"."camera"."type" IS '设备类型:yingshi - 萤石;nvr - NVR摄像头;ipc - IPC 网络摄像头;cascade - 级联摄像头'; |
|||
COMMENT ON COLUMN "public"."camera"."name" IS '设备名称/安装位置'; |
|||
COMMENT ON COLUMN "public"."camera"."channel_name" IS '通道名称'; |
|||
COMMENT ON COLUMN "public"."camera"."external_domain" IS '外域名称'; |
|||
COMMENT ON COLUMN "public"."camera"."serial_no" IS '设备编号'; |
|||
COMMENT ON COLUMN "public"."camera"."cloud_control" IS '云台控制'; |
|||
COMMENT ON COLUMN "public"."camera"."high_definition" IS '高清支持'; |
|||
COMMENT ON COLUMN "public"."camera"."voice" IS '语音对讲支持'; |
|||
COMMENT ON COLUMN "public"."camera"."memory_card" IS '内存卡容量'; |
|||
COMMENT ON COLUMN "public"."camera"."vender_id" IS '设备厂商id'; |
|||
COMMENT ON COLUMN "public"."camera"."cascade_type" IS '级联方式:up - 上级联;down - 下级联'; |
|||
COMMENT ON COLUMN "public"."camera"."longitude" IS '经度'; |
|||
COMMENT ON COLUMN "public"."camera"."latitude" IS '维度'; |
|||
COMMENT ON COLUMN "public"."camera"."forbidden" IS '是否禁用'; |
|||
COMMENT ON COLUMN "public"."camera"."recycle_time" IS '放入回收站时间'; |
|||
COMMENT ON COLUMN "public"."camera"."delete" IS '是否彻底删除'; |
|||
COMMENT ON COLUMN "public"."camera"."model" IS '型号'; |
|||
COMMENT ON COLUMN "public"."camera"."top_serial_no" IS 'gb设备 level=0 的 steamid '; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for camera_ability |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."camera_ability"; |
|||
CREATE TABLE "public"."camera_ability" ( |
|||
"id" int4 NOT NULL, |
|||
"ability" varchar(64) COLLATE "pg_catalog"."default" NOT NULL |
|||
) |
|||
; |
|||
COMMENT ON TABLE "public"."camera_ability" IS '摄像机能力'; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of camera_ability |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."camera_ability" VALUES (1, '普通摄像头'); |
|||
INSERT INTO "public"."camera_ability" VALUES (2, '人流量计数'); |
|||
INSERT INTO "public"."camera_ability" VALUES (3, '热成像'); |
|||
INSERT INTO "public"."camera_ability" VALUES (4, 'AI摄像头'); |
|||
INSERT INTO "public"."camera_ability" VALUES (1314, '其他'); |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for camera_ability_bind |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."camera_ability_bind"; |
|||
CREATE TABLE "public"."camera_ability_bind" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('camera_ability_bind_id_seq'::regclass), |
|||
"camera_id" int4 NOT NULL, |
|||
"ability_id" int4 NOT NULL |
|||
) |
|||
; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for camera_kind |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."camera_kind"; |
|||
CREATE TABLE "public"."camera_kind" ( |
|||
"id" int4 NOT NULL, |
|||
"kind" varchar(64) COLLATE "pg_catalog"."default" NOT NULL |
|||
) |
|||
; |
|||
COMMENT ON TABLE "public"."camera_kind" IS '摄像机类型'; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of camera_kind |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."camera_kind" VALUES (1, '枪机'); |
|||
INSERT INTO "public"."camera_kind" VALUES (2, '球机'); |
|||
INSERT INTO "public"."camera_kind" VALUES (1314, '其他'); |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for camera_remark |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."camera_remark"; |
|||
CREATE TABLE "public"."camera_remark" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('camera_remark_id_seq'::regclass), |
|||
"camera_id" int4 NOT NULL, |
|||
"remark" varchar(256) COLLATE "pg_catalog"."default" NOT NULL |
|||
) |
|||
; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for gbCamera |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."gbCamera"; |
|||
CREATE TABLE "public"."gbCamera" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('gb_id_seq'::regclass), |
|||
"level" int4, |
|||
"parent" varchar(32) COLLATE "pg_catalog"."default", |
|||
"streamid" varchar(255) COLLATE "pg_catalog"."default", |
|||
"online" varchar(255) COLLATE "pg_catalog"."default", |
|||
"manufactuer" varchar(255) COLLATE "pg_catalog"."default", |
|||
"model" varchar(255) COLLATE "pg_catalog"."default", |
|||
"civilCode" varchar(255) COLLATE "pg_catalog"."default", |
|||
"adddress" varchar(255) COLLATE "pg_catalog"."default", |
|||
"name" varchar(255) COLLATE "pg_catalog"."default", |
|||
"Addr" varchar(255) COLLATE "pg_catalog"."default", |
|||
"Sipip" varchar(255) COLLATE "pg_catalog"."default", |
|||
"ipctype" varchar(255) COLLATE "pg_catalog"."default", |
|||
"registerTime" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying, |
|||
"updateTime" varchar(255) COLLATE "pg_catalog"."default", |
|||
"playUrl" jsonb |
|||
) |
|||
; |
|||
COMMENT ON COLUMN "public"."gbCamera"."playUrl" IS '播放地址集合'; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for nvr |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."nvr"; |
|||
CREATE TABLE "public"."nvr" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('nvr_id_seq'::regclass), |
|||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
|||
"vender_id" int4, |
|||
"serial_no" varchar(64) COLLATE "pg_catalog"."default" NOT NULL, |
|||
"region_code" varchar(64) COLLATE "pg_catalog"."default", |
|||
"longitude" numeric(16,12) NOT NULL, |
|||
"latitude" numeric(16,12) NOT NULL, |
|||
"create_time" timestamptz(6) NOT NULL DEFAULT now(), |
|||
"channel_count" int4, |
|||
"port" varchar(32) COLLATE "pg_catalog"."default", |
|||
"delete" bool NOT NULL DEFAULT false, |
|||
"create_user_id" int4 NOT NULL |
|||
) |
|||
; |
|||
COMMENT ON COLUMN "public"."nvr"."vender_id" IS '设备厂家id'; |
|||
COMMENT ON COLUMN "public"."nvr"."serial_no" IS '设备编号'; |
|||
COMMENT ON COLUMN "public"."nvr"."region_code" IS '行政区码'; |
|||
COMMENT ON COLUMN "public"."nvr"."create_time" IS '创建时间'; |
|||
COMMENT ON COLUMN "public"."nvr"."channel_count" IS '通道数'; |
|||
COMMENT ON COLUMN "public"."nvr"."port" IS '端口'; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for secret_yingshi |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."secret_yingshi"; |
|||
CREATE TABLE "public"."secret_yingshi" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('secret_yingshi_id_seq'::regclass), |
|||
"key" varchar(512) COLLATE "pg_catalog"."default" NOT NULL, |
|||
"secret" varchar(512) COLLATE "pg_catalog"."default" NOT NULL, |
|||
"token" varchar(512) COLLATE "pg_catalog"."default", |
|||
"expire" varchar(512) COLLATE "pg_catalog"."default" |
|||
) |
|||
; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of secret_yingshi |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."secret_yingshi" VALUES (2, '3ea2b502f6804d64b43e4cb3d135665c', '331c85c5b7ce76179f6eb7dccb8aeb27', 'at.culo424j9drz8atx9uikeq5e2mzkhnhx-490csubqrh-1o3hcaz-szuvfax6f', '1657681218109'); |
|||
INSERT INTO "public"."secret_yingshi" VALUES (3, 'd0704fb9d5d14a6682c1c1d592c12512', '93d023269495b86be62cdfdcf34a6cd1', 'at.1y2mk5fh2myswbkp017pmvdi0v1zbdrw-5j39z78wsp-0x4vi2j-a3mxjlt32', '1657683606281'); |
|||
INSERT INTO "public"."secret_yingshi" VALUES (1, '5d16a667e1c2423d9d0d634f781810b4', '0cc4e1ec4e6a53ea3dabeb09cd5f468b', 'at.9gq3xwwbazkk33y177ucqtk936bmd0sz-41x4xf24sh-1cn7x82-4lf7davve', '1657681803201'); |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for t_upload_comm_http |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."t_upload_comm_http"; |
|||
CREATE TABLE "public"."t_upload_comm_http" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('t_upload_comm_http_id_seq'::regclass), |
|||
"content" json NOT NULL, |
|||
"enable" bool NOT NULL DEFAULT true, |
|||
"description" varchar(255) COLLATE "pg_catalog"."default" |
|||
) |
|||
; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for vender |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS "public"."vender"; |
|||
CREATE TABLE "public"."vender" ( |
|||
"id" int4 NOT NULL DEFAULT nextval('vender_id_seq'::regclass), |
|||
"name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL |
|||
) |
|||
; |
|||
COMMENT ON TABLE "public"."vender" IS '设备厂商'; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of vender |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."vender" VALUES (2, '海康威视'); |
|||
INSERT INTO "public"."vender" VALUES (3, '大华'); |
|||
INSERT INTO "public"."vender" VALUES (1, '飞尚科技'); |
|||
INSERT INTO "public"."vender" VALUES (1314, '其他'); |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
ALTER SEQUENCE "public"."camera_ability_bind_id_seq" |
|||
OWNED BY "public"."camera_ability_bind"."id"; |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
ALTER SEQUENCE "public"."camera_id_seq" |
|||
OWNED BY "public"."camera"."id"; |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
ALTER SEQUENCE "public"."camera_remark_id_seq" |
|||
OWNED BY "public"."camera_remark"."id"; |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
SELECT setval('"public"."gbCamera_id_seq"', 2, false); |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
ALTER SEQUENCE "public"."nvr_id_seq" |
|||
OWNED BY "public"."nvr"."id"; |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
ALTER SEQUENCE "public"."secret_yingshi_id_seq" |
|||
OWNED BY "public"."secret_yingshi"."id"; |
|||
SELECT setval('"public"."secret_yingshi_id_seq"', 4, true); |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
SELECT setval('"public"."t_upload_comm_http_id_seq"', 2, false); |
|||
|
|||
-- ---------------------------- |
|||
-- Alter sequences owned by |
|||
-- ---------------------------- |
|||
ALTER SEQUENCE "public"."vender_id_seq" |
|||
OWNED BY "public"."vender"."id"; |
|||
SELECT setval('"public"."vender_id_seq"', 4, true); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table ax_project |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "ax_project_id_uindex" ON "public"."ax_project" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table ax_project |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."ax_project" ADD CONSTRAINT "ax_project_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table camera |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "camera_id_uindex" ON "public"."camera" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table camera |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table camera_ability |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "camera_ability_id_uindex" ON "public"."camera_ability" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table camera_ability |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera_ability" ADD CONSTRAINT "camera_ability_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table camera_ability_bind |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "camera_ability_bind_id_uindex" ON "public"."camera_ability_bind" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table camera_ability_bind |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera_ability_bind" ADD CONSTRAINT "camera_ability_bind_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table camera_kind |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "camera_kind_id_uindex" ON "public"."camera_kind" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table camera_kind |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera_kind" ADD CONSTRAINT "camera_kind_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table camera_remark |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "camera_remark_id_uindex" ON "public"."camera_remark" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table camera_remark |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera_remark" ADD CONSTRAINT "camera_remark_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table gbCamera |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."gbCamera" ADD CONSTRAINT "gbCamera1_copy1_pkey" PRIMARY KEY ("id"); |
|||
|
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table nvr |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "nvr_id_uindex" ON "public"."nvr" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table nvr |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."nvr" ADD CONSTRAINT "nvr_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table secret_yingshi |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "secret_yingshi_id_uindex" ON "public"."secret_yingshi" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table secret_yingshi |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."secret_yingshi" ADD CONSTRAINT "secret_yingshi_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table t_upload_comm_http |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."t_upload_comm_http" ADD CONSTRAINT "t_upload_comm_http_pkey" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Indexes structure for table vender |
|||
-- ---------------------------- |
|||
CREATE UNIQUE INDEX "vender_id_uindex" ON "public"."vender" USING btree ( |
|||
"id" "pg_catalog"."int4_ops" ASC NULLS LAST |
|||
); |
|||
|
|||
-- ---------------------------- |
|||
-- Primary Key structure for table vender |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."vender" ADD CONSTRAINT "vender_pk" PRIMARY KEY ("id"); |
|||
|
|||
-- ---------------------------- |
|||
-- Foreign Keys structure for table camera |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_camera_kind_id_fk" FOREIGN KEY ("kind_id") REFERENCES "public"."camera_kind" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_nvr_id_fk" FOREIGN KEY ("nvr_id") REFERENCES "public"."nvr" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_secret_yingshi_id_fk" FOREIGN KEY ("yingshi_secret_id") REFERENCES "public"."secret_yingshi" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
ALTER TABLE "public"."camera" ADD CONSTRAINT "camera_vender_id_fk" FOREIGN KEY ("vender_id") REFERENCES "public"."vender" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
|
|||
-- ---------------------------- |
|||
-- Foreign Keys structure for table camera_ability_bind |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera_ability_bind" ADD CONSTRAINT "camera_ability_bind_camera_ability_id_fk" FOREIGN KEY ("ability_id") REFERENCES "public"."camera_ability" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
ALTER TABLE "public"."camera_ability_bind" ADD CONSTRAINT "camera_ability_bind_camera_id_fk" FOREIGN KEY ("camera_id") REFERENCES "public"."camera" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
|
|||
-- ---------------------------- |
|||
-- Foreign Keys structure for table camera_remark |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."camera_remark" ADD CONSTRAINT "camera_remark_camera_id_fk" FOREIGN KEY ("camera_id") REFERENCES "public"."camera" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
|||
|
|||
-- ---------------------------- |
|||
-- Foreign Keys structure for table nvr |
|||
-- ---------------------------- |
|||
ALTER TABLE "public"."nvr" ADD CONSTRAINT "nvr_vender_id_fk" FOREIGN KEY ("vender_id") REFERENCES "public"."vender" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; |
@ -0,0 +1,186 @@ |
|||
create table if not exists "user" |
|||
( |
|||
id serial not null, |
|||
pep_user_id integer not null, |
|||
role character varying[], |
|||
correlation_project integer[], |
|||
last_in_time timestamp with time zone, |
|||
in_times integer default 0 not null, |
|||
online_duration integer default 0, |
|||
last_in_address varchar(256), |
|||
disabled boolean default false not null, |
|||
deleted boolean default false not null, |
|||
update_time timestamp with time zone default now(), |
|||
constraint user_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on column "user".pep_user_id is '项企对应用户id'; |
|||
|
|||
comment on column "user".role is '角色 也对应权限 admin 管理员 / all 全部角色 / data_analyst 数据分析 / after_sale 售后运维 / resource_manage 资源管理 / customer_service 客户服务'; |
|||
|
|||
comment on column "user".correlation_project is '关联的项目管理的项目id'; |
|||
|
|||
comment on column "user".online_duration is '在线时长 单位 s'; |
|||
|
|||
comment on column "user".last_in_address is '上次登录地点'; |
|||
|
|||
create unique index if not exists user_id_uindex |
|||
on "user" (id); |
|||
|
|||
create table if not exists project_correlation |
|||
( |
|||
id serial not null, |
|||
anxin_project_id integer[] not null, |
|||
pep_project_id integer[] not null, |
|||
create_time timestamp with time zone not null, |
|||
create_user integer not null, |
|||
name varchar(64), |
|||
constraint project_correlation_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on table project_correlation is '安心云项目和项目管理项目关系映射绑定'; |
|||
|
|||
comment on column project_correlation.pep_project_id is '项目管理的项目id'; |
|||
|
|||
create unique index if not exists project_correlation_id_uindex |
|||
on project_correlation (id); |
|||
|
|||
create table if not exists action_log |
|||
( |
|||
id serial not null, |
|||
user_id integer, |
|||
time timestamp with time zone not null, |
|||
action varchar(256), |
|||
expand_params jsonb, |
|||
constraint action_log_pk |
|||
primary key (id), |
|||
constraint action_log_user_id_fk |
|||
foreign key (user_id) references "user" |
|||
); |
|||
|
|||
comment on table action_log is '动态日志'; |
|||
|
|||
comment on column action_log.action is '动态内容'; |
|||
|
|||
create unique index if not exists action_log_id_uindex |
|||
on action_log (id); |
|||
|
|||
create table if not exists quick_link |
|||
( |
|||
id serial not null, |
|||
user_id integer not null, |
|||
link varchar(256) not null, |
|||
constraint quick_link_pk |
|||
primary key (id), |
|||
constraint quick_link_user_id_fk |
|||
foreign key (user_id) references "user" |
|||
); |
|||
|
|||
comment on table quick_link is '对应我的常用工具功能'; |
|||
|
|||
create unique index if not exists quick_link_id_uindex |
|||
on quick_link (id); |
|||
|
|||
create table if not exists project_app |
|||
( |
|||
id serial not null, |
|||
name varchar(32) not null, |
|||
url varchar(1024) not null, |
|||
project_id integer not null, |
|||
constraint project_app_pk |
|||
primary key (id), |
|||
constraint project_app_project_correlation_id_fk |
|||
foreign key (project_id) references project_correlation |
|||
); |
|||
|
|||
create table if not exists app_alarm |
|||
( |
|||
id serial not null, |
|||
serial_number varchar(32), |
|||
project_app_id integer, |
|||
app_domain varchar(512), |
|||
alarm_content varchar(1024), |
|||
create_time timestamp with time zone not null, |
|||
update_time timestamp with time zone, |
|||
confirm varchar(1024), |
|||
router varchar(1024), |
|||
status_code varchar(8), |
|||
constraint app_alarm_pk |
|||
primary key (id), |
|||
constraint app_alarm_project_app_id_fk |
|||
foreign key (project_app_id) references project_app |
|||
); |
|||
|
|||
comment on table app_alarm is '应用异常'; |
|||
|
|||
comment on column app_alarm.serial_number is '自定义编号'; |
|||
|
|||
comment on column app_alarm.project_app_id is '对应的项目id'; |
|||
|
|||
comment on column app_alarm.app_domain is '应用域名'; |
|||
|
|||
comment on column app_alarm.alarm_content is '告警信息'; |
|||
|
|||
comment on column app_alarm.confirm is '确认信息'; |
|||
|
|||
comment on column app_alarm.router is '路由'; |
|||
|
|||
comment on column app_alarm.status_code is '状态码'; |
|||
|
|||
create unique index if not exists app_alarm_id_uindex |
|||
on app_alarm (id); |
|||
|
|||
create table if not exists app_inspection |
|||
( |
|||
id serial not null, |
|||
project_app_id integer, |
|||
create_time timestamp with time zone not null, |
|||
screenshot character varying[], |
|||
noted_pep_user_id integer, |
|||
noted_time timestamp with time zone, |
|||
constraint app_inspection_pk |
|||
primary key (id), |
|||
constraint app_inspection_project_app_id_fk |
|||
foreign key (project_app_id) references project_app |
|||
); |
|||
|
|||
comment on table app_inspection is '应用巡检'; |
|||
|
|||
comment on column app_inspection.screenshot is '截图存储路径'; |
|||
|
|||
comment on column app_inspection.noted_pep_user_id is '核验人员'; |
|||
|
|||
create unique index if not exists app_inspection_id_uindex |
|||
on app_inspection (id); |
|||
|
|||
create unique index if not exists project_app_id_uindex |
|||
on project_app (id); |
|||
|
|||
create table if not exists alarm_push_config |
|||
( |
|||
id serial not null, |
|||
name varchar(32) not null, |
|||
pep_project_id integer[] not null, |
|||
alarm_type character varying[], |
|||
receiver_pep_user_id integer[], |
|||
time_type character varying[], |
|||
create_time timestamp with time zone not null, |
|||
create_user_id integer not null, |
|||
disable boolean default false not null, |
|||
constraint alarm_push_config_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on table alarm_push_config is '告警推送配置'; |
|||
|
|||
comment on column alarm_push_config.alarm_type is '监听的告警类型'; |
|||
|
|||
comment on column alarm_push_config.receiver_pep_user_id is '接收人id 项企'; |
|||
|
|||
comment on column alarm_push_config.time_type is '通知时效'; |
|||
|
|||
create unique index if not exists alarm_push_config_id_uindex |
|||
on alarm_push_config (id); |
|||
|
@ -0,0 +1 @@ |
|||
INSERT INTO "user" ("pep_user_id", "role") VALUES (1, ARRAY['SuperAdmin']); |
@ -0,0 +1,4 @@ |
|||
alter table app_inspection |
|||
add description varchar(1024); |
|||
|
|||
alter table app_inspection alter column screenshot type varchar(1024) using screenshot::varchar(1024); |
@ -1,14 +0,0 @@ |
|||
create table if not exists camera_remark |
|||
( |
|||
id serial not null, |
|||
camera_id integer not null, |
|||
remark varchar(256) not null, |
|||
constraint camera_remark_pk |
|||
primary key (id), |
|||
constraint camera_remark_camera_id_fk |
|||
foreign key (camera_id) references camera |
|||
); |
|||
|
|||
create unique index if not exists camera_remark_id_uindex |
|||
on camera_remark (id); |
|||
|
@ -1,17 +0,0 @@ |
|||
{ |
|||
// 使用 IntelliSense 了解相关属性。 |
|||
// 悬停以查看现有属性的描述。 |
|||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 |
|||
"version": "0.2.0", |
|||
"configurations": [ |
|||
{ |
|||
"type": "node", |
|||
"request": "launch", |
|||
"name": "启动程序", |
|||
"skipFiles": [ |
|||
"<node_internals>/**" |
|||
], |
|||
"program": "${workspaceFolder}\\index.js" |
|||
} |
|||
] |
|||
} |
@ -1,69 +0,0 @@ |
|||
try { |
|||
const { Pool, Client } = require('pg') |
|||
const XLSX = require('xlsx') |
|||
const path = require('path') |
|||
|
|||
// 连接数据库
|
|||
const pool = new Pool({ |
|||
user: 'postgres', |
|||
host: '10.8.30.32', |
|||
database: 'video_access', |
|||
password: '123', |
|||
port: 5432, |
|||
}) |
|||
|
|||
const fun = async () => { |
|||
// note: we don't try/catch this because if connecting throws an exception
|
|||
// we don't need to dispose of the client (it will be undefined)
|
|||
const client = await pool.connect() |
|||
try { |
|||
await client.query('BEGIN') |
|||
|
|||
// 读取数据文件
|
|||
let workbook = XLSX.readFile(path.join(__dirname, '云录制错误码.xlsx')) |
|||
let firstSheetName = workbook.SheetNames[0]; |
|||
let worksheet = workbook.Sheets[firstSheetName]; |
|||
let res = XLSX.utils.sheet_to_json(worksheet); |
|||
|
|||
// console.log(res);
|
|||
|
|||
for (let d of res) { |
|||
let statusRes = await client.query(`SELECT * FROM camera_status WHERE status=$1`, [d['错误码']]); |
|||
let statusRows = statusRes.rows |
|||
|
|||
if (statusRows.length) { |
|||
|
|||
} else { |
|||
console.log(`增加${d['错误码']}`); |
|||
const statusInQuery = `INSERT INTO "camera_status" (platform, status, describe, paraphrase) VALUES($1, $2, $3, $4) RETURNING id;` |
|||
const statusRows = (await client.query(statusInQuery, ['yingshi', d['错误码'], d['错误描述'], d['释义']])).rows |
|||
// console.log(statusRows);
|
|||
if (d['解决方案']) { |
|||
let resolveArr = d['解决方案'].split(';'); |
|||
// await client.query(`DELETE FROM "camera_status_solution" WHERE status_id=$1`, [statusRows[0].id]);
|
|||
for (let r of resolveArr) { |
|||
await client.query( |
|||
`INSERT INTO "camera_status_resolve" (status_id, resolve) VALUES($1, $2) RETURNING id;`, |
|||
[statusRows[0].id, r] |
|||
) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
// await client.query('ROLLBACK')
|
|||
await client.query('COMMIT') |
|||
console.log('执行完毕~') |
|||
} catch (e) { |
|||
await client.query('ROLLBACK') |
|||
console.log('执行错误~') |
|||
throw e |
|||
} finally { |
|||
client.release(); |
|||
} |
|||
} |
|||
|
|||
fun() |
|||
} catch (error) { |
|||
console.error(error) |
|||
} |
@ -1,16 +0,0 @@ |
|||
{ |
|||
"name": "appkey-generator", |
|||
"version": "1.0.0", |
|||
"description": "tool", |
|||
"main": "index.js", |
|||
"scripts": { |
|||
"test": "mocha", |
|||
"start": "set NODE_ENV=development&&node index" |
|||
}, |
|||
"author": "liu", |
|||
"license": "ISC", |
|||
"dependencies": { |
|||
"pg": "^7.18.2", |
|||
"xlsx": "^0.17.1" |
|||
} |
|||
} |
@ -1,141 +0,0 @@ |
|||
|
|||
-- ---------------------------- |
|||
-- Records of camera_status |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."camera_status" VALUES (2, 'yingshi', '5000', '服务端内部处理异常', '服务端内部错误码', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (3, 'yingshi', '5400', '私有化协议vtm检测私有化协议中码流类型小于0或者设备序列号为空等非法参数场景返回(app不重试取流)', '客户端参数出错', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (4, 'yingshi', '5402', '回放找不到录像文件', '设备回放找不到录像文件', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (5, 'yingshi', '5403', '操作码或信令密钥与设备不匹配', '操作码或信令密钥与设备不匹配', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (6, 'yingshi', '5404', '设备不在线', '设备不在线', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (7, 'yingshi', '5405', '流媒体向设备发送或接受信令超时/cas响应超时', '设备回应信令10秒超时', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (8, 'yingshi', '5406', 'token失效', 'token失效', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (9, 'yingshi', '5407', '客户端的URL格式错误', '客户端的URL格式错误', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (10, 'yingshi', '5409', '预览开启隐私保护', '预览开启隐私保护', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (11, 'yingshi', '5411', 'token无权限', 'token无权限、用户无权限', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (12, 'yingshi', '5412', 'session不存在', 'session不存在', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (13, 'yingshi', '5413', '验证token的他异常(不具体)', 'token验证失败', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (14, 'yingshi', '5415', '设备通道错', '设备判断请求通道不存在', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (15, 'yingshi', '5416', '设备资源受限', '设备资源受限', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (16, 'yingshi', '5451', '设备不支持的码流类型', '设备不支持的码流类型', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (17, 'yingshi', '5452', '设备链接流媒体服务器失败', '设备链接流媒体服务器失败', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (18, 'yingshi', '5454', '流媒体中关于设备取流会话不存在', '流媒体中关于设备取流会话不存在', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (19, 'yingshi', '5455', '设备通道未关联', '设备通道未关联', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (20, 'yingshi', '5456', '设备通道关联设备不在线', '设备通道关联设备不在线', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (21, 'yingshi', '5457', '客户端不支持端到端加密', '客户端不支持端到端加密', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (22, 'yingshi', '5458', '设备不支持当前并发ECDH密', '设备不支持当前并发ECDH密', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (23, 'yingshi', '5459', 'VTDU 处理ECDH 加密失败', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (24, 'yingshi', '5492', '设备不支持的命令', '设备不支持的命令', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (25, 'yingshi', '5500', '服务器处理失败', '服务器处理失败', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (26, 'yingshi', '5503', 'vtm返回分配vtdu失败', 'vtm返回分配vtdu失败', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (27, 'yingshi', '5504', '流媒体vtdu达到最大负载', '流媒体vtdu达到最大负载', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (28, 'yingshi', '5544', '设备返回无视频源', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (29, 'yingshi', '5545', '视频分享时间已经结束', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (30, 'yingshi', '5546', 'vtdu返回达到取流并发路数限制', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (31, 'yingshi', '5547', 'vtdu返回开放平台用户并发限制', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (32, 'yingshi', '5556', 'ticket校验失败', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (33, 'yingshi', '5557', '回放服务器等待流头超时', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (34, 'yingshi', '5558', '查找录像开始时间错误', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (35, 'yingshi', '5560', '群组分享取流二次验证失败', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (36, 'yingshi', '5561', '分享群组用户被锁住', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (37, 'yingshi', '5562', '群组分享用户权限变更', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (38, 'yingshi', '5563', '认证服务连接失败', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (39, 'yingshi', '5564', '认证超时', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (40, 'yingshi', '5565', '缓存无效', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (41, 'yingshi', '5566', '不在分享时间内预览', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (42, 'yingshi', '5567', '分享通道被锁定', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (43, 'yingshi', '5568', '未找到认证类型', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (44, 'yingshi', '5569', '认证返回的参数异常', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (45, 'yingshi', '5600', '分享设备不在分享时间内', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (46, 'yingshi', '5601', '群组分享用户没权限', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (47, 'yingshi', '5602', '群组分享权限变更', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (48, 'yingshi', '5530', '机房故障不可用', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (49, 'yingshi', '5701', 'cas信令返回格式错误', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (50, 'yingshi', '5702', 'SPGW请求Cas、Status透传超时', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (51, 'yingshi', '5703', 'SPGW请求http不通', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (52, 'yingshi', '6001', '客户端参数出错', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (53, 'yingshi', '6099', '客户端默认错误', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (54, 'yingshi', '6101', '不支持的命令', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (55, 'yingshi', '6102', '设备流头发送失败', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (56, 'yingshi', '6103', 'cas/设备返回错误1', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (57, 'yingshi', '6104', 'cas/设备返回错误-1', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (58, 'yingshi', '6105', '设备返回错误码3', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (59, 'yingshi', '6106', '设备返回错误码4', '一般常见于多通道设 备预览 1、通道不存在 2、通道子码流不存在 3、通道不在线', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (60, 'yingshi', '6107', '设备返回错误码5', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (61, 'yingshi', '6108', 'cas信令回应重复', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (62, 'yingshi', '6109', '视频广场取消分享', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (63, 'yingshi', '6110', '设备信令默认错误', '设备错误返回的错误码,不具体', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (64, 'yingshi', '6501', '设备数据链路和实际链路不匹配', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (65, 'yingshi', '6502', '设备数据链路重复建立连接', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (66, 'yingshi', '6503', '设备数据链路端口不匹配', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (67, 'yingshi', '6504', '缓存设备数据链路失败(内存块不足)', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (68, 'yingshi', '6505', '设备发送确认头消息重复', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (69, 'yingshi', '6506', '设备数据先于确定头部到达', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (70, 'yingshi', '6508', '设备数据头部长度非法', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (71, 'yingshi', '6509', '索引找不到设备数据管理块', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (72, 'yingshi', '6510', '设备数据链路vtdu内存块协议状态不匹配', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (73, 'yingshi', '6511', '设备数据头部没有streamkey错误', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (74, 'yingshi', '6512', '设备数据头部非法(较笼统)', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (75, 'yingshi', '6513', '设备数据长度过小', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (76, 'yingshi', '6514', '设备老协议推流头部没有streamkey错误', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (77, 'yingshi', '6515', '设备老协议推流数据非法', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (78, 'yingshi', '6516', '设备老协议索引找不到内存管理块', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (79, 'yingshi', '6517', '设备老协议推流数据非法', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (80, 'yingshi', '6518', '设备数据包过大', NULL, 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (81, 'yingshi', '6519', '设备推流链路网络不稳定', '设备长时间未推流超时', 'f', NULL); |
|||
INSERT INTO "public"."camera_status" VALUES (82, 'yingshi', '6520', '设备推流链路网络不稳定(默认)', '设备网络异常', 'f', NULL); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
-- ---------------------------- |
|||
-- Records of camera_status_resolve |
|||
-- ---------------------------- |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (2, 2, '检测服务端是否正常'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (3, 3, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (4, 4, '检查是否有存储卡并且接触良好'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (5, 6, '检查设备网络'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (6, 6, '重启设备接入萤石云'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (7, 7, '检查设备网络'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (8, 7, '重启设备'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (9, 8, '刷新重试或者重启设备'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (10, 9, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (11, 13, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (12, 14, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (13, 15, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (14, 16, '刷新重试或者切换到高清模式'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (15, 17, '检查设备网络,重启设备,刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (16, 19, '检查设备通道是否关联'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (17, 20, '检查设备通道是否上线'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (18, 25, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (19, 26, 'vtdu服务异常,请请稍后重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (20, 27, '服务器负载达到上限,请稍后重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (21, 28, '设备是否接触良好'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (22, 28, '如果一直无法解决,请联系技术支持'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (23, 30, '请升级为企业版,放开并发限制'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (24, 31, '请确定开放平台用户预览是否超过用户并发数量限制'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (25, 33, '刷新重试,检测设备网络,重启设备'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (26, 48, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (27, 49, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (28, 50, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (29, 51, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (30, 52, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (31, 54, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (32, 55, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (33, 56, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (34, 57, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (35, 58, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (36, 59, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (37, 60, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (38, 61, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (39, 63, '刷新重试,或者重启设备'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (40, 64, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (41, 65, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (42, 66, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (43, 67, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (44, 68, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (45, 69, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (46, 70, '刷新重试,或者重启设备'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (47, 71, '刷新重试'); |
|||
INSERT INTO "public"."camera_status_resolve" VALUES (48, 80, '刷新重试,或者重启设备'); |
|||
|
@ -1,140 +0,0 @@ |
|||
create table if not exists camera_status |
|||
( |
|||
id serial not null, |
|||
platform varchar(32) not null, |
|||
status varchar(32) not null, |
|||
describe varchar(1024), |
|||
paraphrase varchar(1024), |
|||
forbidden boolean default false not null, |
|||
paraphrase_custom varchar(1024), |
|||
constraint camera_status_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on column camera_status.platform is '平台分类 yingshi gb'; |
|||
|
|||
comment on column camera_status.describe is '错误描述'; |
|||
|
|||
comment on column camera_status.paraphrase is '释义'; |
|||
|
|||
comment on column camera_status.forbidden is '是否禁用'; |
|||
|
|||
comment on column camera_status.paraphrase_custom is '自定义释义'; |
|||
|
|||
create unique index if not exists camera_status_id_uindex |
|||
on camera_status (id); |
|||
|
|||
|
|||
|
|||
create table if not exists camera_status_log |
|||
( |
|||
id serial not null, |
|||
status_id integer not null, |
|||
time timestamp not null, |
|||
constraint camera_status_log_pk |
|||
primary key (id), |
|||
constraint camera_status_log_camera_status_id_fk |
|||
foreign key (status_id) references camera_status |
|||
); |
|||
|
|||
create unique index if not exists camera_status_log_id_uindex |
|||
on camera_status_log (id); |
|||
|
|||
create unique index if not exists camera_status_log_id_uindex_2 |
|||
on camera_status_log (id); |
|||
|
|||
|
|||
create table if not exists camera_status_push_config |
|||
( |
|||
id serial not null, |
|||
name varchar(64) not null, |
|||
push_way varchar(32) not null, |
|||
notice_way varchar(32) not null, |
|||
create_user integer not null, |
|||
forbidden boolean default false not null, |
|||
timing varchar(32), |
|||
constraint camera_online_status_push_config_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on column camera_status_push_config.push_way is '推送方式 email / phone'; |
|||
|
|||
comment on column camera_status_push_config.notice_way is '通知方式 offline / online / timing'; |
|||
|
|||
comment on column camera_status_push_config.timing is '定时推送时间'; |
|||
|
|||
create unique index if not exists camera_online_status_push_config_id_uindex |
|||
on camera_status_push_config (id); |
|||
|
|||
|
|||
|
|||
create table if not exists camera_status_push_log |
|||
( |
|||
id serial not null, |
|||
push_config_id integer, |
|||
receiver jsonb not null, |
|||
time timestamp, |
|||
push_way varchar(128) not null, |
|||
constraint camera_status_push_log_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on table camera_status_push_log is '上下线推送日志'; |
|||
|
|||
create unique index if not exists camera_status_push_log_id_uindex |
|||
on camera_status_push_log (id); |
|||
|
|||
|
|||
|
|||
create table if not exists camera_status_push_monitor |
|||
( |
|||
id serial not null, |
|||
config_id integer not null, |
|||
camera_id integer not null, |
|||
constraint camera_status_push_monitor_pk |
|||
primary key (id), |
|||
constraint camera_status_push_monitor_camera_id_fk |
|||
foreign key (camera_id) references camera, |
|||
constraint camera_status_push_monitor_camera_status_push_config_id_fk |
|||
foreign key (config_id) references camera_status_push_config |
|||
); |
|||
|
|||
create unique index if not exists camera_status_push_monitor_id_uindex |
|||
on camera_status_push_monitor (id); |
|||
|
|||
|
|||
|
|||
create table if not exists camera_status_push_receiver |
|||
( |
|||
id serial not null, |
|||
config_id integer not null, |
|||
receiver varchar(64) not null, |
|||
constraint camera_status_push_receiver_pk |
|||
primary key (id), |
|||
constraint camera_status_push_receiver_camera_status_push_config_id_fk |
|||
foreign key (config_id) references camera_status_push_config |
|||
); |
|||
|
|||
comment on column camera_status_push_receiver.receiver is '接受者信息 邮箱或者电话号码'; |
|||
|
|||
create unique index if not exists camera_status_push_receiver_id_uindex |
|||
on camera_status_push_receiver (id); |
|||
|
|||
|
|||
create table if not exists camera_status_resolve |
|||
( |
|||
id serial not null, |
|||
status_id integer not null, |
|||
resolve varchar(1024) not null, |
|||
constraint camera_status_resolve_pk |
|||
primary key (id), |
|||
constraint camera_status_resolve_camera_status_id_fk |
|||
foreign key (status_id) references camera_status |
|||
); |
|||
|
|||
comment on table camera_status_resolve is '错误码解决方案'; |
|||
|
|||
create unique index if not exists camera_status_resolve_id_uindex |
|||
on camera_status_resolve (id); |
|||
|
|||
|
@ -1,21 +0,0 @@ |
|||
alter table camera_status_push_config alter column notice_way type varchar[32] using notice_way::varchar[32]; |
|||
|
|||
|
|||
|
|||
DROP TABLE if exists camera_status_push_log; |
|||
create table if not exists camera_status_push_log |
|||
( |
|||
id serial not null, |
|||
push_config_id integer, |
|||
time timestamp, |
|||
push_way varchar(128) not null, |
|||
camera integer[] not null, |
|||
receiver character varying[] not null, |
|||
constraint camera_status_push_log_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on table camera_status_push_log is '上下线推送日志'; |
|||
|
|||
create unique index if not exists camera_status_push_log_id_uindex |
|||
on camera_status_push_log (id); |
@ -1,5 +0,0 @@ |
|||
alter table camera_status_push_log |
|||
add timing varchar(64); |
|||
|
|||
alter table camera_status_push_log |
|||
add notice_way varchar[]; |
@ -1,4 +0,0 @@ |
|||
alter table camera |
|||
add channel_no varchar(128); |
|||
|
|||
comment on column camera.channel_no is '通道号'; |
@ -1,13 +0,0 @@ |
|||
create table if not exists camera_status_offline_log |
|||
( |
|||
id serial not null, |
|||
camera_id integer not null, |
|||
status varchar(32) not null, |
|||
time timestamp not null, |
|||
constraint camera_status_offline_log_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
create unique index if not exists camera_status_offline_log_id_uindex |
|||
on camera_status_offline_log (id); |
|||
|
@ -1,19 +0,0 @@ |
|||
create table if not exists application |
|||
( |
|||
id serial not null, |
|||
name varchar(32) not null, |
|||
type character varying[], |
|||
app_key varchar(64) not null, |
|||
app_secret varchar(64) not null, |
|||
create_user_id integer not null, |
|||
create_time timestamp not null, |
|||
forbidden boolean default false not null, |
|||
constraint application_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on column application.type is 'web / app / wxapp / other'; |
|||
|
|||
create unique index if not exists application_id_uindex |
|||
on application (id); |
|||
|
@ -1,4 +0,0 @@ |
|||
alter table "gbCamera" |
|||
add did varchar(128); |
|||
|
|||
comment on column "gbCamera".did is '设备自定义id'; |
@ -1,90 +0,0 @@ |
|||
create table if not exists mirror |
|||
( |
|||
id serial not null, |
|||
template varchar(63) not null, |
|||
create_user integer not null, |
|||
create_time timestamp with time zone not null, |
|||
update_time timestamp with time zone, |
|||
title varchar(128), |
|||
show_header boolean not null, |
|||
publish boolean default false not null, |
|||
mid varchar(32) not null, |
|||
publish_time timestamp with time zone, |
|||
constraint mirror_pk |
|||
primary key (id) |
|||
); |
|||
|
|||
comment on column mirror.template is '模板标识'; |
|||
|
|||
create unique index if not exists mirror_id_uindex |
|||
on mirror (id); |
|||
|
|||
create table if not exists mirror_tree |
|||
( |
|||
id serial not null, |
|||
name varchar(64) not null, |
|||
level integer not null, |
|||
dependence integer, |
|||
mirror_id integer not null, |
|||
constraint mirror_tree_pk |
|||
primary key (id), |
|||
constraint mirror_tree_mirror_id_fk |
|||
foreign key (mirror_id) references mirror |
|||
); |
|||
|
|||
comment on table mirror_tree is '镜像服务的树节点'; |
|||
|
|||
comment on column mirror_tree.level is '层级标注'; |
|||
|
|||
create unique index if not exists mirror_tree_id_uindex |
|||
on mirror_tree (id); |
|||
|
|||
create table if not exists mirror_filter_group |
|||
( |
|||
id serial not null, |
|||
name varchar(64) not null, |
|||
forbidden boolean default false not null, |
|||
mirror_id integer not null, |
|||
constraint mirror_filter_group_pk |
|||
primary key (id), |
|||
constraint mirror_filter_group_mirror_id_fk |
|||
foreign key (mirror_id) references mirror |
|||
); |
|||
|
|||
comment on table mirror_filter_group is '筛选分组'; |
|||
|
|||
create unique index if not exists mirror_filter_group_id_uindex |
|||
on mirror_filter_group (id); |
|||
|
|||
create table if not exists mirror_filter |
|||
( |
|||
id serial not null, |
|||
name varchar(64) not null, |
|||
group_id integer not null, |
|||
constraint mirror_filter_pk |
|||
primary key (id), |
|||
constraint mirror_filter_mirror_filter_group_id_fk |
|||
foreign key (group_id) references mirror_filter_group |
|||
); |
|||
|
|||
create unique index if not exists mirror_filter_id_uindex |
|||
on mirror_filter (id); |
|||
|
|||
create table if not exists mirror_camera |
|||
( |
|||
id serial not null, |
|||
camera_id integer not null, |
|||
tree_ids integer[] not null, |
|||
filter_ids integer[], |
|||
mirror_id integer not null, |
|||
constraint mirror_camera_pk |
|||
primary key (id), |
|||
constraint mirror_camera_camera_id_fk |
|||
foreign key (camera_id) references camera, |
|||
constraint mirror_camera_mirror_id_fk |
|||
foreign key (mirror_id) references mirror |
|||
); |
|||
|
|||
create unique index if not exists mirror_camera_id_uindex |
|||
on mirror_camera (id); |
|||
|
@ -1,17 +0,0 @@ |
|||
{ |
|||
// 使用 IntelliSense 了解相关属性。 |
|||
// 悬停以查看现有属性的描述。 |
|||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 |
|||
"version": "0.2.0", |
|||
"configurations": [ |
|||
{ |
|||
"type": "node", |
|||
"request": "launch", |
|||
"name": "启动程序", |
|||
"skipFiles": [ |
|||
"<node_internals>/**" |
|||
], |
|||
"program": "${workspaceFolder}\\index.js" |
|||
} |
|||
] |
|||
} |
@ -1,8 +0,0 @@ |
|||
|
|||
FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 |
|||
COPY . /var/app |
|||
WORKDIR /var/app |
|||
RUN npm cache clean -f |
|||
RUN rm -rf package-lock.json |
|||
RUN npm install --registry http://10.8.30.22:7000 |
|||
CMD ["node", "index.js"] |
@ -1,156 +0,0 @@ |
|||
try { |
|||
const { Pool, Client } = require('pg') |
|||
const XLSX = require('xlsx') |
|||
const path = require('path') |
|||
const request = require('superagent') |
|||
const moment = require('moment') |
|||
|
|||
// 连接数据库
|
|||
const vcmpPool = new Pool({ |
|||
user: 'FashionAdmin', |
|||
host: '10.8.40.223', |
|||
database: 'video-access', |
|||
password: 'Fas123_', |
|||
port: 5432, |
|||
}) |
|||
const anxinPool = new Pool({ |
|||
user: 'FashionAdmin', |
|||
host: '10.8.40.223', |
|||
database: 'AnxinCloud', |
|||
password: 'Fas123_', |
|||
port: 5432, |
|||
}) |
|||
|
|||
|
|||
const fun = async () => { |
|||
// note: we don't try/catch this because if connecting throws an exception
|
|||
// we don't need to dispose of the client (it will be undefined)
|
|||
const vcmpClient = await vcmpPool.connect() |
|||
const anxinClient = await anxinPool.connect() |
|||
try { |
|||
await vcmpClient.query('BEGIN') |
|||
const yingshiHost = 'https://open.ys7.com/api/' |
|||
// 获取全部萤石摄像头信息
|
|||
const anxinYSRes = await anxinClient.query(`SELECT * FROM t_video_ipc WHERE type=$1`, ['yingshi']); |
|||
// console.log(anxinYSRes);
|
|||
// 获取所有萤石账号信息
|
|||
const secretYSRes = await vcmpClient.query(`SELECT * FROM secret_yingshi`) |
|||
const secretRes = secretYSRes.rows |
|||
// console.log('secretRes', secretRes);
|
|||
|
|||
let addSuccessCount = 0 |
|||
let addRepeatCount = 0 |
|||
let addUnlegalCount = 0 |
|||
let addNoAuthCount = 0 |
|||
for (let c of anxinYSRes.rows) { |
|||
console.log(`处理序列号:${c.serial_no}`) |
|||
if (!c.serial_no) { |
|||
addUnlegalCount += 1 |
|||
continue |
|||
} |
|||
let vcmpExistRes = await vcmpClient.query( |
|||
`SELECT * FROM "gbCamera" WHERE streamid=$1`, [c.serial_no] |
|||
) |
|||
let vcmpExistRows = vcmpExistRes.rows |
|||
|
|||
let cameraExistRes = await vcmpClient.query(`SELECT * FROM camera WHERE serial_no=$1`, [c.serial_no]) |
|||
let cameraRes = cameraExistRes.rows || [] |
|||
|
|||
let repeatCamera = cameraRes.find(cr => { |
|||
return ( |
|||
!cr.channel_no && c.channel_no == 1 |
|||
) || (cr.channel_no == c.channel_no) |
|||
}) |
|||
if (repeatCamera) { |
|||
console.log(`当前设备序列号 ${c.serial_no} 通道号 ${c.channel_no} 已存在`); |
|||
console.log(`已存在 id=${repeatCamera.id} 通道号 ${repeatCamera.channel_no}`); |
|||
addRepeatCount++ |
|||
continue |
|||
} |
|||
|
|||
if (vcmpExistRows.length) { |
|||
let beloneSecretId = null |
|||
let serialUnlegal = false |
|||
for (let s of secretRes) { |
|||
let start = (new Date()).getTime(); |
|||
console.log(`当前查询账号key ${s.key}`); |
|||
if (!s.newToken) { |
|||
const tokenRes = await request.post(`${yingshiHost}lapp/token/get`).query({ |
|||
appKey: s.key, |
|||
appSecret: s.secret |
|||
}) |
|||
console.log(`查询 token 结果`, tokenRes.body); |
|||
|
|||
if (tokenRes.body.code == 200 && tokenRes.body.data) { |
|||
const { accessToken, expireTime } = tokenRes.body.data |
|||
s.newToken = accessToken |
|||
|
|||
} else { |
|||
throw `未能获取萤石token ${s.key} ${tokenRes.body.code}` |
|||
} |
|||
} |
|||
|
|||
while (((new Date()).getTime() - start) < 3000) {//限制频率
|
|||
continue; |
|||
} |
|||
|
|||
// 检测设备所属
|
|||
const cameraState = await request.post(`${yingshiHost}lapp/device/info`).query({ |
|||
accessToken: s.newToken, |
|||
deviceSerial: c.serial_no |
|||
}) |
|||
console.log(`查询设备所属结果`, cameraState.body.code, cameraState.body.msg); |
|||
if (cameraState.body.code == 200) { |
|||
console.log(`所属萤石账号 ${s.key}`); |
|||
beloneSecretId = s.id |
|||
break |
|||
} else if (cameraState.body.code == 20018) { |
|||
|
|||
} else if (cameraState.body.code == 20014) { |
|||
serialUnlegal = true |
|||
break |
|||
} |
|||
} |
|||
if (serialUnlegal) { |
|||
addUnlegalCount++ |
|||
continue |
|||
} |
|||
|
|||
if (!beloneSecretId) { |
|||
console.error('没有查询到所属账号') |
|||
console.log(vcmpExistRows); |
|||
addNoAuthCount++ |
|||
continue |
|||
} |
|||
|
|||
const cameraInQuery = `INSERT INTO "camera" (type, name, serial_no, cloud_control,longitude,latitude,create_time,create_user_id,yingshi_secret_id,gb_id,channel_no) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING id;` |
|||
await vcmpClient.query(cameraInQuery, ['yingshi', c.name, c.serial_no, c.has_ptz, c.longitude, c.latitude, moment().format(), 1, beloneSecretId, vcmpExistRows[0].id, c.channel_no]) |
|||
addSuccessCount++ |
|||
} else { |
|||
console.error('当前序列号不存在,应在 vcmp 添加相应萤石账号'); |
|||
addNoAuthCount++ |
|||
} |
|||
} |
|||
console.log(` |
|||
共 ${anxinYSRes.rows.length} |
|||
添加 ${addSuccessCount} |
|||
已有 ${addRepeatCount} |
|||
序列号不合法 ${addUnlegalCount} |
|||
无所属 ${addNoAuthCount} |
|||
`);
|
|||
// await client.query('ROLLBACK')
|
|||
await vcmpClient.query('COMMIT') |
|||
console.log('执行完毕~') |
|||
} catch (e) { |
|||
await vcmpClient.query('ROLLBACK') |
|||
console.log('执行错误~') |
|||
throw e |
|||
} finally { |
|||
vcmpClient.release(); |
|||
} |
|||
} |
|||
|
|||
fun() |
|||
} catch (error) { |
|||
console.error(error) |
|||
} |
@ -1,18 +0,0 @@ |
|||
{ |
|||
"name": "appkey-generator", |
|||
"version": "1.0.0", |
|||
"description": "tool", |
|||
"main": "index.js", |
|||
"scripts": { |
|||
"test": "mocha", |
|||
"start": "set NODE_ENV=development&&node index" |
|||
}, |
|||
"author": "liu", |
|||
"license": "ISC", |
|||
"dependencies": { |
|||
"moment": "^2.29.4", |
|||
"pg": "^7.18.2", |
|||
"superagent": "3.5.2", |
|||
"xlsx": "^0.17.1" |
|||
} |
|||
} |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 639 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 789 B |
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,18 @@ |
|||
#top-slider{ |
|||
.semi-navigation-item-text{ |
|||
font-size: 13px; |
|||
color: #F2F3F5; |
|||
} |
|||
.semi-navigation-item-icon{ |
|||
color: #F2F3F5; |
|||
} |
|||
.semi-navigation-item-selected{ |
|||
background: none; |
|||
} |
|||
.semi-navigation-item{ |
|||
margin: 0px; |
|||
} |
|||
.semi-navigation-item-text{ |
|||
overflow: inherit; |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
#page-slider{ |
|||
.semi-navigation-sub .semi-navigation-item-selected{ |
|||
background: rgba(0, 90, 189, 0.5); |
|||
color: #F2F3F5; |
|||
} |
|||
.semi-navigation-item-text{ |
|||
color: #F2F3F5; |
|||
} |
|||
.semi-navigation-item-icon{ |
|||
color:#F2F3F5 |
|||
} |
|||
.semi-navigation-sub-title-selected{ |
|||
background: #1D2343; |
|||
.semi-navigation-item-icon{ |
|||
color: #0F7EFB !important; |
|||
} |
|||
.semi-icon-code{ |
|||
color: #0F7EFB !important; |
|||
} |
|||
} |
|||
.semi-navigation{ |
|||
width: 180px; |
|||
} |
|||
.semi-navigation-collapsed{ |
|||
width: 48px !important; |
|||
} |
|||
.semi-button-with-icon{ |
|||
color:#F2F3F5 |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
'use strict'; |
|||
|
|||
import * as console from './console' |
|||
|
|||
export default { |
|||
...console |
|||
} |
@ -0,0 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
import Console from './console'; |
|||
|
|||
export { Console }; |
@ -0,0 +1,15 @@ |
|||
'use strict'; |
|||
|
|||
import reducers from './reducers'; |
|||
import routes from './routes'; |
|||
import actions from './actions'; |
|||
import { getNavItem } from './nav-item'; |
|||
|
|||
export default { |
|||
key: 'console', |
|||
name: '控制台', |
|||
reducers: reducers, |
|||
routes: routes, |
|||
actions: actions, |
|||
getNavItem: getNavItem |
|||
}; |
@ -0,0 +1,15 @@ |
|||
import React from 'react'; |
|||
import { IconCode } from '@douyinfe/semi-icons'; |
|||
|
|||
export function getNavItem (user, dispatch) { |
|||
return ( |
|||
[ |
|||
{ |
|||
itemKey: 'console', |
|||
text: '控制台', |
|||
to: '/console', |
|||
// icon: <IconCode />, |
|||
}, |
|||
] |
|||
); |
|||
} |
@ -0,0 +1,13 @@ |
|||
'use strict'; |
|||
import { Console, } from './containers'; |
|||
|
|||
export default [{ |
|||
type: 'inner', |
|||
route: { |
|||
path: '/console', |
|||
key: 'console', |
|||
breadcrumb: '控制台', |
|||
component: Console, |
|||
// 不设置 component 则面包屑禁止跳转
|
|||
} |
|||
}]; |