Browse Source

修复读取不到长度的情况

dev
CODE 1 year ago
parent
commit
108b77ccb0
  1. 36
      api/app/lib/schedule/alarms_push.js

36
api/app/lib/schedule/alarms_push.js

@ -1,7 +1,7 @@
const moment = require('moment') const moment = require('moment')
let isDev = false let isDev = false
// let isDev = true // isDev = true
let proDebug = false let proDebug = false
proDebug = true proDebug = true
@ -9,10 +9,13 @@ proDebug = true
module.exports = function (app, opts) { module.exports = function (app, opts) {
const alarmsPush = app.fs.scheduleInit( const alarmsPush = app.fs.scheduleInit(
{ {
interval: '12 */1 * * * *', interval: isDev ?
'24 0 */1 * * *' : // 延长运行时间 好debug
'12 */1 * * * *',
// interval: '12 0 0 0 */1 *', // interval: '12 0 0 0 */1 *',
immediate: isDev, immediate: isDev,
proRun: !isDev, proRun: !isDev,
// proRun: true
}, },
async () => { async () => {
try { try {
@ -94,14 +97,13 @@ module.exports = function (app, opts) {
return title return title
} }
console.log('EM推送列表', configListRes); pLog('EM推送列表',);
pLog(configListRes)
for (let { dataValues: c } of configListRes) { for (let { dataValues: c } of configListRes) {
if (c.tacticsParams && c.tactics) { if (c.tacticsParams && c.tactics) {
if (proDebug) { pLog(`当前运行EM配置:id=${c.id} name=${c.name}`);
console.log(`当前运行EM配置:id=${c.id} name=${c.name}`);
}
// pomsProjectId 是个数组 [] // pomsProjectId 是个数组 []
const { strucId, pomsProjectId, pomsStrucFactorId } = c const { strucId, pomsProjectId, pomsStrucFactorId } = c
const { interval, deviceProportion } = c.tacticsParams const { interval, deviceProportion } = c.tacticsParams
@ -210,12 +212,6 @@ module.exports = function (app, opts) {
return s.id return s.id
}) })
// !开发测试用的数据
if (isDev) {
// searchStrucIds = searchStrucIds.concat([991, 1052, 700])
searchStrucIds = searchStrucIds.concat([991])
}
if (searchStrucIds.length) { if (searchStrucIds.length) {
searchStrucIds.unshift(-1) searchStrucIds.unshift(-1)
} else { } else {
@ -323,7 +319,8 @@ module.exports = function (app, opts) {
} }
if (c.alarmType.includes('video_exception')) { if (c.alarmType.includes('video_exception')) {
let videoAlarmSubType = c.alarmSubType ? c.alarmSubType['video_exception'] : [] let videoAlarmSubType = c.alarmSubType ? c.alarmSubType['video_exception'] : []
if (videoAlarmSubType.length == 1) { if (videoAlarmSubType && videoAlarmSubType.length == 1) {
// 一个参数的时候不能兼容 sql 的 in 方法 in (1,2,3)
videoAlarmSubType.push(-1) videoAlarmSubType.push(-1)
} }
videoAlarms = videoAlarms =
@ -1151,8 +1148,6 @@ module.exports = function (app, opts) {
` `
).toPromise() || [] ).toPromise() || []
let factorId = factorData.map(f => f.id) let factorId = factorData.map(f => f.id)
//查询结构物对应的设备 //查询结构物对应的设备
@ -1378,22 +1373,15 @@ module.exports = function (app, opts) {
} }
}) })
} }
} }
}) })
} }
}) })
} }
}) })
} }
}) })
} else { } else {
for (let [index, a] of alarmData.entries()) { for (let [index, a] of alarmData.entries()) {
@ -1560,8 +1548,8 @@ module.exports = function (app, opts) {
if (isDev) { if (isDev) {
// !开发测试用的数据 // !开发测试用的数据
// emails = ['1650192445@qq.com'] emails = ['1650192445@qq.com']
emails = ['wen.lele@free-sun.com.cn'] // emails = ['wen.lele@free-sun.com.cn']
} }
if (proDebug) { if (proDebug) {
console.log('emails', emails); console.log('emails', emails);

Loading…
Cancel
Save