Browse Source

Merge branch 'dev_trial' of https://gitea.anxinyun.cn/free-sun/FS-IOT into dev_trial

release_1.1.1
deartibers 2 years ago
parent
commit
8323f72ce0
  1. 2
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  2. 257
      code/VideoAccess-VCMP/api/app/lib/controllers/status/index.js
  3. 85
      code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js
  4. 71
      code/VideoAccess-VCMP/api/app/lib/index.js
  5. 5
      code/VideoAccess-VCMP/api/app/lib/models/ax_project.js
  6. 8
      code/VideoAccess-VCMP/api/app/lib/models/camera.js
  7. 4
      code/VideoAccess-VCMP/api/app/lib/models/camera_ability_bind.js
  8. 4
      code/VideoAccess-VCMP/api/app/lib/models/camera_remark.js
  9. 79
      code/VideoAccess-VCMP/api/app/lib/models/camera_status.js
  10. 47
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_log.js
  11. 79
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_config.js
  12. 61
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_log.js
  13. 51
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_monitor.js
  14. 47
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_receiver.js
  15. 47
      code/VideoAccess-VCMP/api/app/lib/models/camera_status_resolve.js
  16. 8
      code/VideoAccess-VCMP/api/app/lib/models/gb_camera.js
  17. 4
      code/VideoAccess-VCMP/api/app/lib/models/secret_yingshi.js
  18. 66
      code/VideoAccess-VCMP/api/app/lib/models/vender.js
  19. 44
      code/VideoAccess-VCMP/api/app/lib/routes/status/index.js
  20. 2
      code/VideoAccess-VCMP/api/app/lib/service/socket.js
  21. 2
      code/VideoAccess-VCMP/api/sequelize-automate.config.js
  22. 3
      code/VideoAccess-VCMP/script/.vscode/settings.json
  23. 17
      code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/.vscode/launch.json
  24. 69
      code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/index.js
  25. 16
      code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/package.json
  26. BIN
      code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/云录制错误码.xlsx
  27. 2
      code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js
  28. 4
      code/VideoAccess-VCMP/web/config.js
  29. 2
      code/VideoAccess-VCMP/web/package.json

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

@ -284,7 +284,7 @@ async function banned (ctx) {
const { models } = ctx.fs.dc;
const data = ctx.request.body;
// 向视频服务发送通知
// TODO 向视频服务发送通知
// 库记录
await models.Camera.update({

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

@ -0,0 +1,257 @@
'use strict';
const moment = require('moment')
async function get (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
const { limit, page, orderBy, orderDirection, keyword, forbidden, paraphraseCustom } = ctx.query
const sequelize = ctx.fs.dc.ORM;
let findOption = {
attributes: {
include: [
[sequelize.fn('COUNT', sequelize.col('cameraStatusLogs.id')), 'logCount']
]
},
where: {},
order: [
[orderBy || 'id', orderDirection || 'DESC']
],
distinct: true,
subQuery: false,
group: [
'cameraStatus.id',
'cameraStatusLogs.status_id',
// 'cameraStatusResolves.id'
],
include: [
// {
// model: models.CameraStatusResolve,
// attributes: { exclude: ['statusId'] },
// required: false,
// duplicating: true
// },
{
model: models.CameraStatusLog,
attributes: [],
duplicating: false,
required: false,
}
],
}
if (orderBy) {
if (orderBy == 'logCount') {
findOption.order = sequelize.literal(`"logCount" ${orderDirection || 'DESC'}`)
}
}
if (limit) {
findOption.limit = limit
}
if (page && limit) {
findOption.offset = page * limit
}
if (keyword) {
findOption.where['$or'] = {
describe: {
$like: `%${keyword}%`
},
paraphrase: {
$like: `%${keyword}%`
},
paraphraseCustom: {
$like: `%${keyword}%`
},
}
}
if (forbidden) {
if (forbidden === 'true') {
findOption.where.forbidden = true
} else if (forbidden === 'false') {
findOption.where.forbidden = false
}
}
if (paraphraseCustom) {
if (paraphraseCustom === 'true') {
findOption.where.paraphraseCustom = null
} else if (paraphraseCustom === 'false') {
findOption.where.paraphraseCustom = {
$ne: null
}
}
}
const statusRes = await models.CameraStatus.findAll(findOption)
delete findOption.order
delete findOption.limit
delete findOption.offset
delete findOption.attributes
delete findOption.group
const count = await models.CameraStatus.count(findOption)
const statusIds = statusRes.map(r => r.id)
const statusResolveRes = await models.CameraStatusResolve.findAll({
where: {
statusId: {
$in: statusIds
}
}
})
for (let { dataValues: s } of statusRes) {
const corResolve = statusResolveRes.filter(r => r.statusId === s.id)
s.resolve = corResolve
}
ctx.status = 200;
ctx.body = {
count,
rows: statusRes,
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function getSimpleAll (ctx) {
try {
const models = ctx.fs.dc.models;
const statusRes = await models.CameraStatus.findAll({
attributes: ['id', 'platform', 'status', 'describe'],
})
ctx.status = 200;
ctx.body = statusRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function banned (ctx) {
try {
const { models } = ctx.fs.dc;
const data = ctx.request.body;
// 库记录
await models.CameraStatus.update({
forbidden: data.forbidden
}, {
where: {
id: data.statusId
}
})
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function paraphraseCustom (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
const data = ctx.request.body
await models.CameraStatus.update({
paraphraseCustom: data.paraphrase,
}, {
where: {
id: { $in: data.statusId }
}
})
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function resolveEdit (ctx) {
const transaction = await ctx.fs.dc.orm.transaction();
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
const data = ctx.request.body
await models.CameraStatusResolve.destroy({
where: {
statusId: data.statusId
},
transaction
})
await models.CameraStatusResolve.bulkCreate(
data.resolve.map(r => {
return {
statusId: data.statusId,
resolve: r
}
}),
{ transaction }
)
await transaction.commit();
ctx.status = 204;
} catch (error) {
await transaction.rollback();
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function statusCheck (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
const { status, platform, describe } = ctx.query
if (!status || !platform) {
throw 'status and platform is required'
}
const statusRes = await models.CameraStatus.findOne({
where: {
status,
platform,
},
include: [{
model: models.CameraStatusResolve,
attributes: { exclude: ['statusId'] },
}],
})
if (!statusRes && describe) {
await models.CameraStatus.create({
status, platform, describe
})
}
ctx.status = 200;
ctx.body = statusRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
module.exports = {
get,
getSimpleAll,
banned,
paraphraseCustom,
resolveEdit,
statusCheck,
};

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

@ -0,0 +1,85 @@
'use strict';
const moment = require('moment')
async function edit (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function get (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function banned (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function del (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function copy (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
async function detail (ctx) {
try {
const models = ctx.fs.dc.models;
const { userId, token } = ctx.fs.api
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {}
}
}
module.exports = {
edit, get, banned, del, copy, detail
};

71
code/VideoAccess-VCMP/api/app/lib/index.js

@ -44,19 +44,60 @@ module.exports.entry = function (app, router, opts) {
};
module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Sequelize, models: {} }
require('./models/nvr')(dc);
require('./models/camera_ability')(dc);
require('./models/camera_kind')(dc);
require('./models/camera')(dc);
require('./models/camera_ability_bind')(dc);
require('./models/vender')(dc);
require('./models/secret_yingshi')(dc);
require('./models/gb_camera')(dc);
require('./models/ax_project')(dc);
require('./models/camera_remark')(dc);
// TODO 模型关系摘出来 初始化之后再定义关系才行
// fs.readdirSync(path.join(__dirname, '/models')).forEach((filename) => {
// require(`./models/${filename}`)(dc)
// });
// 加载定义模型 历史写法
// require('./models/nvr')(dc);
// require('./models/camera_ability')(dc);
// require('./models/camera_kind')(dc);
// require('./models/camera')(dc);
// require('./models/camera_ability_bind')(dc);
// require('./models/vender')(dc);
// require('./models/secret_yingshi')(dc);
// require('./models/gb_camera')(dc);
// require('./models/ax_project')(dc);
// require('./models/camera_remark')(dc);
// 模型关系摘出来 初始化之后再定义关系才行
fs.readdirSync(path.join(__dirname, '/models')).forEach((filename) => {
require(`./models/${filename}`)(dc)
});
const {
Nvr, Camera, CameraAbility, CameraAbilityBind, CameraKind, CameraRemark,
GbCamera, SecretYingshi, Vender, CameraStatus, CameraStatusResolve, CameraStatusLog
} = dc.models;
// Nvr.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' });
// User.hasMany(Nvr, { foreignKey: 'userId', sourceKey: 'id' });
Camera.belongsToMany(CameraAbility, { through: CameraAbilityBind, foreignKey: 'cameraId', otherKey: 'abilityId' });
CameraRemark.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(CameraRemark, { foreignKey: 'cameraId', sourceKey: 'id' });
Camera.belongsTo(CameraKind, { foreignKey: 'kindId', targetKey: 'id' });
CameraKind.hasMany(Camera, { foreignKey: 'kindId', sourceKey: 'id' });
Camera.belongsTo(Nvr, { foreignKey: 'nvrId', targetKey: 'id' });
Nvr.hasMany(Camera, { foreignKey: 'nvrId', sourceKey: 'id' });
Nvr.belongsTo(GbCamera, { foreignKey: 'serialNo', targetKey: 'streamid', as: 'gbNvr' });
GbCamera.hasMany(Nvr, { foreignKey: 'serialNo', sourceKey: 'streamid', as: 'gbNvr' });
Camera.belongsTo(GbCamera, { foreignKey: 'gbId', targetKey: 'id' });
GbCamera.hasMany(Camera, { foreignKey: 'gbId', sourceKey: 'id' });
Camera.belongsTo(SecretYingshi, { foreignKey: 'yingshiSecretId', targetKey: 'id' });
SecretYingshi.hasMany(Camera, { foreignKey: 'yingshiSecretId', sourceKey: 'id' });
Camera.belongsTo(Vender, { foreignKey: 'venderId', targetKey: 'id' });
Vender.hasMany(Camera, { foreignKey: 'venderId', sourceKey: 'id' });
Nvr.belongsTo(Vender, { foreignKey: 'venderId', targetKey: 'id' });
Vender.hasMany(Nvr, { foreignKey: 'venderId', sourceKey: 'id' });
CameraStatusResolve.belongsTo(CameraStatus, { foreignKey: 'statusId', targetKey: 'id' });
CameraStatus.hasMany(CameraStatusResolve, { foreignKey: 'statusId', sourceKey: 'id' });
CameraStatusLog.belongsTo(CameraStatus, { foreignKey: 'statusId', targetKey: 'id' });
CameraStatus.hasMany(CameraStatusLog, { foreignKey: 'statusId', sourceKey: 'id' });
};

5
code/VideoAccess-VCMP/api/app/lib/models/ax_project.js

@ -30,11 +30,6 @@ module.exports = dc => {
indexes: []
});
const Nvr = dc.models.Nvr;
// Nvr.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' });
// User.hasMany(Nvr, { foreignKey: 'userId', sourceKey: 'id' });
dc.models.AxProject = AxProject;
return AxProject;
};

8
code/VideoAccess-VCMP/api/app/lib/models/camera.js

@ -272,13 +272,5 @@ module.exports = dc => {
});
dc.models.Camera = Camera;
const CameraKind = dc.models.CameraKind;
Camera.belongsTo(CameraKind, { foreignKey: 'kindId', targetKey: 'id' });
CameraKind.hasMany(Camera, { foreignKey: 'kindId', sourceKey: 'id' });
const Nvr = dc.models.Nvr;
Camera.belongsTo(Nvr, { foreignKey: 'nvrId', targetKey: 'id' });
Nvr.hasMany(Camera, { foreignKey: 'nvrId', sourceKey: 'id' });
return Camera;
};

4
code/VideoAccess-VCMP/api/app/lib/models/camera_ability_bind.js

@ -48,9 +48,5 @@ module.exports = dc => {
});
dc.models.CameraAbilityBind = CameraAbilityBind;
const Camera = dc.models.Camera;
const CameraAbility = dc.models.CameraAbility;
Camera.belongsToMany(CameraAbility, { through: CameraAbilityBind, foreignKey: 'cameraId', otherKey: 'abilityId' });
return CameraAbilityBind;
};

4
code/VideoAccess-VCMP/api/app/lib/models/camera_remark.js

@ -44,9 +44,5 @@ module.exports = dc => {
});
dc.models.CameraRemark = CameraRemark;
const Camera = dc.models.Camera;
CameraRemark.belongsTo(Camera, { foreignKey: 'cameraId', targetKey: 'id' });
Camera.hasMany(CameraRemark, { foreignKey: 'cameraId', sourceKey: 'id' });
return CameraRemark;
};

79
code/VideoAccess-VCMP/api/app/lib/models/camera_status.js

@ -0,0 +1,79 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatus = sequelize.define("cameraStatus", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_id_uindex"
},
platform: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: "平台分类 yingshi gb",
primaryKey: false,
field: "platform",
autoIncrement: false
},
status: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "status",
autoIncrement: false
},
describe: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "错误描述",
primaryKey: false,
field: "describe",
autoIncrement: false
},
paraphrase: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "释义",
primaryKey: false,
field: "paraphrase",
autoIncrement: false
},
forbidden: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: null,
comment: "是否禁用",
primaryKey: false,
field: "forbidden",
autoIncrement: false
},
paraphraseCustom: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "自定义释义",
primaryKey: false,
field: "paraphrase_custom",
autoIncrement: false
}
}, {
tableName: "camera_status",
comment: "",
indexes: []
});
dc.models.CameraStatus = CameraStatus;
return CameraStatus;
};

47
code/VideoAccess-VCMP/api/app/lib/models/camera_status_log.js

@ -0,0 +1,47 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusLog = sequelize.define("cameraStatusLog", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_log_id_uindex_2"
},
statusId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "status_id",
autoIncrement: false,
references: {
key: "id",
model: "cameraStatus"
}
},
time: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "time",
autoIncrement: false
}
}, {
tableName: "camera_status_log",
comment: "",
indexes: []
});
dc.models.CameraStatusLog = CameraStatusLog;
return CameraStatusLog;
};

79
code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_config.js

@ -0,0 +1,79 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusPushConfig = sequelize.define("cameraStatusPushConfig", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_online_status_push_config_id_uindex"
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
},
pushWay: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: "推送方式 email / phone",
primaryKey: false,
field: "push_way",
autoIncrement: false
},
noticeWay: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: "通知方式 offline / online / timing",
primaryKey: false,
field: "notice_way",
autoIncrement: false
},
createUser: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "create_user",
autoIncrement: false
},
forbidden: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "forbidden",
autoIncrement: false
},
timing: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "定时推送时间",
primaryKey: false,
field: "timing",
autoIncrement: false
}
}, {
tableName: "camera_status_push_config",
comment: "",
indexes: []
});
dc.models.CameraStatusPushConfig = CameraStatusPushConfig;
return CameraStatusPushConfig;
};

61
code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_log.js

@ -0,0 +1,61 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusPushLog = sequelize.define("cameraStatusPushLog", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_push_log_id_uindex"
},
pushConfigId: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "push_config_id",
autoIncrement: false
},
receiver: {
type: DataTypes.JSONB,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "receiver",
autoIncrement: false
},
time: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "time",
autoIncrement: false
},
pushWay: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "push_way",
autoIncrement: false
}
}, {
tableName: "camera_status_push_log",
comment: "",
indexes: []
});
dc.models.CameraStatusPushLog = CameraStatusPushLog;
return CameraStatusPushLog;
};

51
code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_monitor.js

@ -0,0 +1,51 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusPushMonitor = sequelize.define("cameraStatusPushMonitor", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_push_monitor_id_uindex"
},
configId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "config_id",
autoIncrement: false,
references: {
key: "id",
model: "cameraStatusPushConfig"
}
},
cameraId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "camera_id",
autoIncrement: false,
references: {
key: "id",
model: "camera"
}
}
}, {
tableName: "camera_status_push_monitor",
comment: "",
indexes: []
});
dc.models.CameraStatusPushMonitor = CameraStatusPushMonitor;
return CameraStatusPushMonitor;
};

47
code/VideoAccess-VCMP/api/app/lib/models/camera_status_push_receiver.js

@ -0,0 +1,47 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusPushReceiver = sequelize.define("cameraStatusPushReceiver", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_push_receiver_id_uindex"
},
configId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "config_id",
autoIncrement: false,
references: {
key: "id",
model: "cameraStatusPushConfig"
}
},
receiver: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: "接受者信息 邮箱或者电话号码",
primaryKey: false,
field: "receiver",
autoIncrement: false
}
}, {
tableName: "camera_status_push_receiver",
comment: "",
indexes: []
});
dc.models.CameraStatusPushReceiver = CameraStatusPushReceiver;
return CameraStatusPushReceiver;
};

47
code/VideoAccess-VCMP/api/app/lib/models/camera_status_resolve.js

@ -0,0 +1,47 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const CameraStatusResolve = sequelize.define("cameraStatusResolve", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "camera_status_resolve_id_uindex"
},
statusId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "status_id",
autoIncrement: false,
references: {
key: "id",
model: "cameraStatus"
}
},
resolve: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "resolve",
autoIncrement: false
}
}, {
tableName: "camera_status_resolve",
comment: "",
indexes: []
});
dc.models.CameraStatusResolve = CameraStatusResolve;
return CameraStatusResolve;
};

8
code/VideoAccess-VCMP/api/app/lib/models/gb_camera.js

@ -156,14 +156,6 @@ module.exports = dc => {
indexes: []
});
const Nvr = dc.models.Nvr;
Nvr.belongsTo(GbCamera, { foreignKey: 'serialNo', targetKey: 'streamid', as: 'gbNvr' });
GbCamera.hasMany(Nvr, { foreignKey: 'serialNo', sourceKey: 'streamid', as: 'gbNvr' });
const Camera = dc.models.Camera;
Camera.belongsTo(GbCamera, { foreignKey: 'gbId', targetKey: 'id' });
GbCamera.hasMany(Camera, { foreignKey: 'gbId', sourceKey: 'id' });
dc.models.GbCamera = GbCamera;
return GbCamera;
};

4
code/VideoAccess-VCMP/api/app/lib/models/secret_yingshi.js

@ -57,10 +57,6 @@ module.exports = dc => {
indexes: []
});
const Camera = dc.models.Camera;
Camera.belongsTo(SecretYingshi, { foreignKey: 'yingshiSecretId', targetKey: 'id' });
SecretYingshi.hasMany(Camera, { foreignKey: 'yingshiSecretId', sourceKey: 'id' });
dc.models.SecretYingshi = SecretYingshi;
return SecretYingshi;

66
code/VideoAccess-VCMP/api/app/lib/models/vender.js

@ -2,43 +2,35 @@
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const Vender = sequelize.define("vender", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "vender_id_uindex"
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
}
}, {
tableName: "vender",
comment: "",
indexes: []
});
const Camera = dc.models.Camera;
Camera.belongsTo(Vender, { foreignKey: 'venderId', targetKey: 'id' });
Vender.hasMany(Camera, { foreignKey: 'venderId', sourceKey: 'id' });
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const Vender = sequelize.define("vender", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "vender_id_uindex"
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
}
}, {
tableName: "vender",
comment: "",
indexes: []
});
const Nvr = dc.models.Nvr;
Nvr.belongsTo(Vender, { foreignKey: 'venderId', targetKey: 'id' });
Vender.hasMany(Nvr, { foreignKey: 'venderId', sourceKey: 'id' });
dc.models.Vender = Vender;
dc.models.Vender = Vender;
return Vender;
return Vender;
};

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

@ -0,0 +1,44 @@
'use strict';
const status = require('../../controllers/status');
const push = require('../../controllers/status/push');
module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/status'] = { content: '获取状态码', visible: false };
router.get('/status', status.get);
app.fs.api.logAttr['GET/status/simple_all'] = { content: '获取全部状态码简略信息', visible: false };
router.get('/status/simple_all', status.getSimpleAll);
app.fs.api.logAttr['PUT/status/banned'] = { content: '禁用状态码自定义', visible: false };
router.put('/status/banned', status.banned);
app.fs.api.logAttr['POST/status/custom'] = { content: '自定义状态码释义', visible: false };
router.post('/status/custom', status.paraphraseCustom);
app.fs.api.logAttr['POST/status/resolve'] = { content: '编辑解决方案', visible: false };
router.post('/status/resolve', status.resolveEdit);
app.fs.api.logAttr['GET/status/check'] = { content: '查取指定状态码信息', visible: false };
router.get('/status/check', status.statusCheck);
// 信鸽推送
app.fs.api.logAttr['POST/status/push'] = { content: '编辑推送配置', visible: false };
router.post('/status/push', push.edit);
app.fs.api.logAttr['GET/status/push'] = { content: '获取推送配置', visible: false };
router.get('/status/push', push.get);
app.fs.api.logAttr['PUT/status/push/banned'] = { content: '禁用推送配置', visible: false };
router.put('/status/push/banned', push.banned);
app.fs.api.logAttr['DEL/status/push/:pushId'] = { content: '删除推送配置', visible: false };
router.delete('/status/push/:pushId', push.del);
app.fs.api.logAttr['GET/status/push/:pushId/copy'] = { content: '赋值推送配置', visible: false };
router.get('/status/push/:pushId/copy', push.copy);
app.fs.api.logAttr['GET/status/push/:pushId/detail'] = { content: '获取推送配置详情', visible: false };
router.get('/status/push/:pushId/detail', push.detail);
// 信鸽推送 END
};

2
code/VideoAccess-VCMP/api/app/lib/service/socket.js

@ -21,7 +21,7 @@ module.exports = async function factory (app, opts) {
// app.socket.to(roomId).emit('TEST', { someProperty: `【星域 ROOM:${roomId}】呼叫自然选择号!!!`, })
// }
// app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', })
app.socket.emit('TEST', { someProperty: '【广播】呼叫青铜时代号!!!', })
// app.socket.emit('CAMERA_ONLINE', {
// ipctype: 'yingshi',

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

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

3
code/VideoAccess-VCMP/script/.vscode/settings.json

@ -0,0 +1,3 @@
{
"editor.wordWrap": "on"
}

17
code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/.vscode/launch.json

@ -0,0 +1,17 @@
{
// 使 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"
}
]
}

69
code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/index.js

@ -0,0 +1,69 @@
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)
}

16
code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/package.json

@ -0,0 +1,16 @@
{
"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"
}
}

BIN
code/VideoAccess-VCMP/script/1.1.1/data/1_update_status_code_data/云录制错误码.xlsx

Binary file not shown.

2
code/VideoAccess-VCMP/web/client/src/layout/actions/webSocket.js

@ -22,7 +22,7 @@ export function initWebSocket ({ ioUrl, token }) {
return dispatch => {
const socket = io(
ioUrl
// 'http://127.0.0.1:4000'
// 'http://10.8.30.7:4000'
, {
query: {
token: token

4
code/VideoAccess-VCMP/web/config.js

@ -12,6 +12,7 @@ dev && console.log('\x1B[33m%s\x1b[0m', '请遵循并及时更新 readme.md,
// // 启动参数
args.option(['p', 'port'], '启动端口');
args.option(['u', 'api-url'], 'webapi的URL');
args.option('apiVcmpUrl', 'webapi的URL 外网可访问');
args.option('apiAuthUrl', 'IOT 鉴权 api');
args.option('apiAnxinyunUrl', '安心云 api');
args.option('iotAuthWeb', 'IOT 鉴权 web');
@ -20,6 +21,7 @@ args.option('iotVideoServer', 'IOT 后端视频服务鉴权');
const flags = args.parse(process.argv);
const API_URL = process.env.API_URL || flags.apiUrl;
const API_VCMP_URL = process.env.API_VCMP_URL || flags.apiVcmpUrl;
const API_AUTH_URL = process.env.API_AUTH_URL || flags.apiAuthUrl;
const IOT_AUTH_WEB = process.env.IOT_AUTH_WEB || flags.iotAuthWeb;
const API_ANXINYUN_URL = process.env.API_ANXINYUN_URL || flags.apiAnxinyunUrl;
@ -68,7 +70,7 @@ const product = {
}, {
entry: require('./routes').entry,
opts: {
apiUrl: API_URL,
apiUrl: API_VCMP_URL,
iotAuthWeb: IOT_AUTH_WEB,
iotVideoServer: IOT_VIDEO_SERVER,
staticRoot: './client',

2
code/VideoAccess-VCMP/web/package.json

@ -7,7 +7,7 @@
"test": "mocha",
"start-vite": "cross-env NODE_ENV=developmentVite npm run start-params",
"start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5000 -u http://10.8.30.7:4000 --apiAuthUrl http://10.8.30.7:4200 --apiAnxinyunUrl http://10.8.30.7:4100 --iotAuthWeb http://localhost:5200 --iotVideoServer http://221.230.55.27:8081",
"start-params": "node server -p 5000 -u http://10.8.30.7:4000 --apiVcmpUrl http://localhost:4000 --apiAuthUrl http://10.8.30.7:4200 --apiAnxinyunUrl http://10.8.30.7:4100 --iotAuthWeb http://localhost:5200 --iotVideoServer http://221.230.55.27:8081",
"deploy": "export NODE_ENV=production&& npm run build && node server",
"build-dev": "cross-env NODE_ENV=development&&webpack --config webpack.config.js",
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js"

Loading…
Cancel
Save