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

Loading…
Cancel
Save