Browse Source

fix 复制出来的策略未处于禁用状态

release_1.1.2
巴林闲侠 2 years ago
parent
commit
452cc0ed1c
  1. 4
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js
  2. 1
      code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js
  3. 9
      code/VideoAccess-VCMP/api/app/lib/models/camera.js
  4. 37
      code/VideoAccess-VCMP/api/app/lib/schedule/cameraStatePush.js
  5. 4
      code/VideoAccess-VCMP/api/app/lib/utils/push.js
  6. 4
      code/VideoAccess-VCMP/script/1.1.2/schema/3.update_camera_channel_no.sql

4
code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js

@ -31,6 +31,7 @@ async function createYingshi (ctx) {
const {
id, name, cloudControl, highDefinition, memoryCard,
voice, kindId, abilityId, rtmp, serialNo, longitude, latitude,
channelNo,
} = ctx.request.body;
let handleCameraId = id
errMsg = (handleCameraId ? '修改' : '添加') + errMsg
@ -47,7 +48,8 @@ async function createYingshi (ctx) {
voice, longitude, latitude, kindId, rtmp,
serialNo: String(serialNo).toUpperCase(),
yingshiSecretId: beloneSecret.id,
gbId: corGbYingshiRes ? corGbYingshiRes.id : null
gbId: corGbYingshiRes ? corGbYingshiRes.id : null,
channelNo,
}
if (handleCameraId) {

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

@ -325,6 +325,7 @@ async function copy (ctx) {
delete copyConfig.cameraStatusPushReceivers
copyConfig.name += '-副本'
copyConfig.createUser = userId
copyConfig.forbidden = true
let newConfig = await models.CameraStatusPushConfig.create(copyConfig, {
transaction
})

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

@ -265,6 +265,15 @@ module.exports = dc => {
field: "gb_id",
autoIncrement: false,
},
channelNo: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: '通道号',
primaryKey: false,
field: "channel_no",
autoIncrement: false
},
}, {
tableName: "camera",
comment: "",

37
code/VideoAccess-VCMP/api/app/lib/schedule/cameraStatePush.js

@ -4,7 +4,7 @@ module.exports = function (app, opts) {
const cameraOnlinePush = app.fs.scheduleInit(
{
interval: '* */15 * * * *',
// interval: '*/15 * * * * *',
interval: '*/15 * * * * *',
immediate: false,
proRun: true,
},
@ -39,9 +39,10 @@ module.exports = function (app, opts) {
const offlineStatusRes = await models.CameraStatusOfflineLog.findAll({
where: {
cameraId: { $in: cameraIds },
time: {
$between: [moment(timeNow).subtract(15, 'minutes').format(), timeNow]
}
// time: {
// $between: [moment(timeNow).subtract(15, 'minutes').format(), timeNow]
// }
},
include: [{
model: models.Camera,
@ -57,7 +58,7 @@ module.exports = function (app, opts) {
// 只要出现一次上线 就做上线推送
for (let s of offlineStatusRes) {
if (cameraStatusMap[s.cameraId]) {
cameraStatusMap.status.push({
cameraStatusMap[s.cameraId].status.push({
status: s.status,
time: s.time,
})
@ -121,7 +122,7 @@ module.exports = function (app, opts) {
if (offArr.length && c.noticeWay && c.noticeWay.includes('offline')) {
if (c.pushWay == 'email') {
// 邮件
let text = `${corUser[0].namePresent}】账号下的设备,截止【${moment(timeNow).format('MM月DD日 HH时mm分')}】,有${offArr.length}个设备掉线:\n`
let text = `${corUser[0].username}】账号下的设备,截止【${moment(timeNow).format('MM月DD日 HH时mm分')}】,有${offArr.length}个设备掉线:\n`
text += offArr.map(o => `${o.name}】于【${o.time}】掉线,`).join('\n')
text += `\n请及时处理!`
await pushByEmail({
@ -133,10 +134,10 @@ module.exports = function (app, opts) {
} else if (c.pushWay == 'phone') {
// 短信
let templateParam = {
name: corUser[0].namePresent,
name: corUser[0].username,
}
let useTempCode = 'SMS_247900122'
// let text = `【${corUser[0].namePresent}】账号下的`
// let text = `【${corUser[0].username}】账号下的`
if (offArr.length == 1) {
// text += `【${offArr[0].name}】离线,请及时处理!【${moment(offArr[0].time).format('MM月DD日 HH时mm分')}】`
templateParam.deviceName = `${offArr[0].name}`
@ -191,7 +192,7 @@ module.exports = function (app, opts) {
}
}
let text = `${corUser[0].namePresent}】账号下的设备:\n`
let text = `${corUser[0].username}】账号下的设备:\n`
text += onArr.map(o => `${o.name}】于【${moment(o.offTime).format('MM月DD日HH时mm分')}】掉线,【${moment(o.time).format('MM月DD日HH时mm分')}】已恢复`).join('\n')
await pushByEmail({
email: receiver,
@ -201,9 +202,9 @@ module.exports = function (app, opts) {
await models.CameraStatusPushLog.create({ ...logData, pushWay: 'email', noticeWay: ['online'], camera: onArr.map(o => o.cameraId) })
} else if (c.pushWay == 'phone') {
// 短信
// let text = `【${corUser[0].namePresent}】账号下的`
// let text = `【${corUser[0].username}】账号下的`
let templateParam = {
name: corUser[0].namePresent,
name: corUser[0].username,
}
let useTempCode = 'SMS_247820204'
if (onArr.length == 1) {
@ -245,6 +246,7 @@ module.exports = function (app, opts) {
interval: '* */5 * * * *',
// interval: '*/10 * * * * *', // dev
immediate: false,
proRun: false,
proRun: true,
},
async () => {
@ -258,6 +260,7 @@ module.exports = function (app, opts) {
noticeWay: {
$contains: ['timing']
},
// !!! 此时此刻
timing: moment(timeNow).format('HH:mm')
},
include: [
@ -321,7 +324,7 @@ module.exports = function (app, opts) {
group: ['cameraId'],
})
if (offlineTimeRes.length) {
let text = `${corUser[0].namePresent}】账号下的设备,截止${moment(timeNow).format('MM月DD日 HH时mm分')},有${offlineRes.length}个设备掉线:\n`
let text = `${corUser[0].username}】账号下的设备,截止${moment(timeNow).format('MM月DD日 HH时mm分')},有${offlineRes.length}个设备掉线:\n`
text += offlineTimeRes.map(o => {
let corCamera = offlineRes.find(c => c.id == o.cameraId)
if (corCamera) {
@ -339,15 +342,15 @@ module.exports = function (app, opts) {
}
} else if (c.pushWay == 'phone') {
// 短信
// let text = `【${corUser[0].namePresent}】账号下截止${moment(timeNow).format('YYYY年MM月DD日 HH时')},有${offlineRes.length}个设备掉线,请及时处理!`
// let text = `【${corUser[0].username}】账号下截止${moment(timeNow).format('YYYY年MM月DD日 HH时')},有${offlineRes.length}个设备掉线,请及时处理!`
await pushBySms({
phone: receiver,
templateCode: 'SMS_247785195',
templateParam: JSON.stringify({
name: corUser[0].namePresent,
templateCode: 'SMS_248095009',
templateParam: {
name: corUser[0].username,
time: moment(timeNow).format('YYYY年MM月DD日 HH时'),
deviceCount: offlineRes.length,
}),
},
})
await models.CameraStatusPushLog.create({ ...logData, pushWay: 'phone', noticeWay: ['timing'] })
}

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

@ -15,8 +15,8 @@ module.exports = function (app, opts) {
apiVersion: '2017-05-25'//固定
});
const SendSmsRes = await client.request('SendSms', {
"PhoneNumbers": `${phone.join(',')}`,//接收短信的手机号码。
"SignName": "尚视",//短信签名名称。必须是已添加、并通过审核的短信签名。
"PhoneNumbers": phone.join(','),//接收短信的手机号码。
"SignName": "飞尚尚视",//短信签名名称。必须是已添加、并通过审核的短信签名。
"TemplateCode": templateCode,//短信模板ID。必须是已添加、并通过审核的短信签名;且发送国际/港澳台消息时,请使用国际/港澳台短信模版。
"TemplateParam": JSON.stringify(templateParam)//短信模板变量对应的实际值,JSON格式。
}, {

4
code/VideoAccess-VCMP/script/1.1.2/schema/3.update_camera_channel_no.sql

@ -0,0 +1,4 @@
alter table camera
add channel_no varchar(128);
comment on column camera.channel_no is '通道号';
Loading…
Cancel
Save