Browse Source

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

release_1.1.2
巴林闲侠 3 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 { const {
id, name, cloudControl, highDefinition, memoryCard, id, name, cloudControl, highDefinition, memoryCard,
voice, kindId, abilityId, rtmp, serialNo, longitude, latitude, voice, kindId, abilityId, rtmp, serialNo, longitude, latitude,
channelNo,
} = ctx.request.body; } = ctx.request.body;
let handleCameraId = id let handleCameraId = id
errMsg = (handleCameraId ? '修改' : '添加') + errMsg errMsg = (handleCameraId ? '修改' : '添加') + errMsg
@ -47,7 +48,8 @@ async function createYingshi (ctx) {
voice, longitude, latitude, kindId, rtmp, voice, longitude, latitude, kindId, rtmp,
serialNo: String(serialNo).toUpperCase(), serialNo: String(serialNo).toUpperCase(),
yingshiSecretId: beloneSecret.id, yingshiSecretId: beloneSecret.id,
gbId: corGbYingshiRes ? corGbYingshiRes.id : null gbId: corGbYingshiRes ? corGbYingshiRes.id : null,
channelNo,
} }
if (handleCameraId) { if (handleCameraId) {

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

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

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

@ -265,6 +265,15 @@ module.exports = dc => {
field: "gb_id", field: "gb_id",
autoIncrement: false, autoIncrement: false,
}, },
channelNo: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: '通道号',
primaryKey: false,
field: "channel_no",
autoIncrement: false
},
}, { }, {
tableName: "camera", tableName: "camera",
comment: "", 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( const cameraOnlinePush = app.fs.scheduleInit(
{ {
interval: '* */15 * * * *', interval: '* */15 * * * *',
// interval: '*/15 * * * * *', interval: '*/15 * * * * *',
immediate: false, immediate: false,
proRun: true, proRun: true,
}, },
@ -39,9 +39,10 @@ module.exports = function (app, opts) {
const offlineStatusRes = await models.CameraStatusOfflineLog.findAll({ const offlineStatusRes = await models.CameraStatusOfflineLog.findAll({
where: { where: {
cameraId: { $in: cameraIds }, cameraId: { $in: cameraIds },
time: {
$between: [moment(timeNow).subtract(15, 'minutes').format(), timeNow] // time: {
} // $between: [moment(timeNow).subtract(15, 'minutes').format(), timeNow]
// }
}, },
include: [{ include: [{
model: models.Camera, model: models.Camera,
@ -57,7 +58,7 @@ module.exports = function (app, opts) {
// 只要出现一次上线 就做上线推送 // 只要出现一次上线 就做上线推送
for (let s of offlineStatusRes) { for (let s of offlineStatusRes) {
if (cameraStatusMap[s.cameraId]) { if (cameraStatusMap[s.cameraId]) {
cameraStatusMap.status.push({ cameraStatusMap[s.cameraId].status.push({
status: s.status, status: s.status,
time: s.time, time: s.time,
}) })
@ -121,7 +122,7 @@ module.exports = function (app, opts) {
if (offArr.length && c.noticeWay && c.noticeWay.includes('offline')) { if (offArr.length && c.noticeWay && c.noticeWay.includes('offline')) {
if (c.pushWay == 'email') { 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 += offArr.map(o => `${o.name}】于【${o.time}】掉线,`).join('\n')
text += `\n请及时处理!` text += `\n请及时处理!`
await pushByEmail({ await pushByEmail({
@ -133,10 +134,10 @@ module.exports = function (app, opts) {
} else if (c.pushWay == 'phone') { } else if (c.pushWay == 'phone') {
// 短信 // 短信
let templateParam = { let templateParam = {
name: corUser[0].namePresent, name: corUser[0].username,
} }
let useTempCode = 'SMS_247900122' let useTempCode = 'SMS_247900122'
// let text = `【${corUser[0].namePresent}】账号下的` // let text = `【${corUser[0].username}】账号下的`
if (offArr.length == 1) { if (offArr.length == 1) {
// text += `【${offArr[0].name}】离线,请及时处理!【${moment(offArr[0].time).format('MM月DD日 HH时mm分')}】` // text += `【${offArr[0].name}】离线,请及时处理!【${moment(offArr[0].time).format('MM月DD日 HH时mm分')}】`
templateParam.deviceName = `${offArr[0].name}` 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') 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({ await pushByEmail({
email: receiver, 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) }) await models.CameraStatusPushLog.create({ ...logData, pushWay: 'email', noticeWay: ['online'], camera: onArr.map(o => o.cameraId) })
} else if (c.pushWay == 'phone') { } else if (c.pushWay == 'phone') {
// 短信 // 短信
// let text = `【${corUser[0].namePresent}】账号下的` // let text = `【${corUser[0].username}】账号下的`
let templateParam = { let templateParam = {
name: corUser[0].namePresent, name: corUser[0].username,
} }
let useTempCode = 'SMS_247820204' let useTempCode = 'SMS_247820204'
if (onArr.length == 1) { if (onArr.length == 1) {
@ -245,6 +246,7 @@ module.exports = function (app, opts) {
interval: '* */5 * * * *', interval: '* */5 * * * *',
// interval: '*/10 * * * * *', // dev // interval: '*/10 * * * * *', // dev
immediate: false, immediate: false,
proRun: false,
proRun: true, proRun: true,
}, },
async () => { async () => {
@ -258,6 +260,7 @@ module.exports = function (app, opts) {
noticeWay: { noticeWay: {
$contains: ['timing'] $contains: ['timing']
}, },
// !!! 此时此刻
timing: moment(timeNow).format('HH:mm') timing: moment(timeNow).format('HH:mm')
}, },
include: [ include: [
@ -321,7 +324,7 @@ module.exports = function (app, opts) {
group: ['cameraId'], group: ['cameraId'],
}) })
if (offlineTimeRes.length) { 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 => { text += offlineTimeRes.map(o => {
let corCamera = offlineRes.find(c => c.id == o.cameraId) let corCamera = offlineRes.find(c => c.id == o.cameraId)
if (corCamera) { if (corCamera) {
@ -339,15 +342,15 @@ module.exports = function (app, opts) {
} }
} else if (c.pushWay == 'phone') { } 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({ await pushBySms({
phone: receiver, phone: receiver,
templateCode: 'SMS_247785195', templateCode: 'SMS_248095009',
templateParam: JSON.stringify({ templateParam: {
name: corUser[0].namePresent, name: corUser[0].username,
time: moment(timeNow).format('YYYY年MM月DD日 HH时'), time: moment(timeNow).format('YYYY年MM月DD日 HH时'),
deviceCount: offlineRes.length, deviceCount: offlineRes.length,
}), },
}) })
await models.CameraStatusPushLog.create({ ...logData, pushWay: 'phone', noticeWay: ['timing'] }) 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'//固定 apiVersion: '2017-05-25'//固定
}); });
const SendSmsRes = await client.request('SendSms', { const SendSmsRes = await client.request('SendSms', {
"PhoneNumbers": `${phone.join(',')}`,//接收短信的手机号码。 "PhoneNumbers": phone.join(','),//接收短信的手机号码。
"SignName": "尚视",//短信签名名称。必须是已添加、并通过审核的短信签名。 "SignName": "飞尚尚视",//短信签名名称。必须是已添加、并通过审核的短信签名。
"TemplateCode": templateCode,//短信模板ID。必须是已添加、并通过审核的短信签名;且发送国际/港澳台消息时,请使用国际/港澳台短信模版。 "TemplateCode": templateCode,//短信模板ID。必须是已添加、并通过审核的短信签名;且发送国际/港澳台消息时,请使用国际/港澳台短信模版。
"TemplateParam": JSON.stringify(templateParam)//短信模板变量对应的实际值,JSON格式。 "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