Browse Source

问题修改

dev
wenlele 2 years ago
parent
commit
cb64511098
  1. 51
      api/app/lib/schedule/alarms_push.js

51
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 let isDev = true
let proDebug = false let proDebug = false
proDebug = true proDebug = true
@ -9,8 +9,8 @@ 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: '12 */1 * * * *',
// interval: '12 0 0 0 */1 *', interval: '12 0 0 0 */1 *',
immediate: isDev, immediate: isDev,
proRun: !isDev, proRun: !isDev,
}, },
@ -102,7 +102,7 @@ module.exports = function (app, opts) {
const corPomsProject = pomsProjectRes.filter(poms => pomsProjectId.includes(poms.id)) const corPomsProject = pomsProjectRes.filter(poms => pomsProjectId.includes(poms.id))
let curAnxinProjectId = new Set() let curAnxinProjectId = new Set()
let pepProjectName_ = [] let pepProjectName_ = []
let pepProject_name = [] let pepProject_name = [] //当前有关联的项目,后面往对应项目里面插入对应的结构物-监测因素-告警源
for (let { dataValues: poms } of corPomsProject) { for (let { dataValues: poms } of corPomsProject) {
if (poms.pepProjectId) { if (poms.pepProjectId) {
// 找对应的项企项目 // 找对应的项企项目
@ -1163,6 +1163,7 @@ module.exports = function (app, opts) {
x.factor.forEach(f => { x.factor.forEach(f => {
let rowspan3 = 0 let rowspan3 = 0
if (f.devices.length) { if (f.devices.length) {
f.devicesLength = f.devices.length
f.devices = f.devices.filter(b => b.alarmDatas && b.alarmDatas.length > 0) f.devices = f.devices.filter(b => b.alarmDatas && b.alarmDatas.length > 0)
if (f.devices.length) { if (f.devices.length) {
f.devices.forEach(c => { f.devices.forEach(c => {
@ -1195,6 +1196,7 @@ module.exports = function (app, opts) {
h.rowspan = rowspan1 h.rowspan = rowspan1
}) })
console.log('数据组合', JSON.stringify(pepProject_name)); console.log('数据组合', JSON.stringify(pepProject_name));
//
dataAlarmG1 = pepProject_name dataAlarmG1 = pepProject_name
} }
@ -1205,8 +1207,6 @@ module.exports = function (app, opts) {
if (!alarmData.length) { if (!alarmData.length) {
return '' return ''
} }
strucMap = { ...strucMap }
pepProject_name = [...pepProject_name]
ifEmailSend = true ifEmailSend = true
let tableTitlePrefix = titlePrefix + '告警源' let tableTitlePrefix = titlePrefix + '告警源'
let newAddCount = 0 let newAddCount = 0
@ -1214,37 +1214,10 @@ module.exports = function (app, opts) {
let alarmContent = '' let alarmContent = ''
let alarmHtmlTitle = packageTableTitle(alarmTitleArr) let alarmHtmlTitle = packageTableTitle(alarmTitleArr)
// // if (type == 1) {
// let projectData = []
// //按项目分类
// pepProject_name.map(c => {
// let OneProjectdata = []
// alarmData.map(a => {
// let OneStructure = (strucMap[a.StructureId] || {}).pepProject || []
// if (OneStructure.includes(c.id)) {
// OneProjectdata.push({
// ...a,
// pepProjectId: c.id,
// pepProjectName: c.name
// })
// }
// })
// if (OneProjectdata.length) {
// projectData.push(OneProjectdata)
// }
// })
// let projectType = []
// projectData.map(p => {
// })
// // }
if (type == 1) { if (type == 1) {
alarmData.map((h, hi) => { alarmData.map((h, hi) => {
if (h.projects && h.projects.length) { if (h.projects && h.projects.length) {
@ -1273,20 +1246,20 @@ module.exports = function (app, opts) {
switch (t.k) { switch (t.k) {
case 'name': case 'name':
if (showOne1) { if (showOne1 && showOne2 && showOne3) {
tableData += `<th rowspan=${h.rowspan}>${h[t.k] || ''}</th>` tableData += `<th rowspan=${h.rowspan}>${h[t.k] || ''}</th>`
} }
break; break;
case 'Structure': case 'Structure':
if (showOne2) { if (showOne2 && showOne3) {
tableData += `<th rowspan=${x.rowspan}>${x['name'] || ''}</th>` tableData += `<th rowspan=${x.rowspan}>${x['name'] || ''}</th>`
} }
break; break;
case 'factor': case 'factor':
if (showOne3) { if (showOne3) {
tableData += `<th rowspan=${f.rowspan}>${f['name'] || ''}</th>` tableData += `<th rowspan=${f.rowspan}>${(f['name']+'('+f.rowspan+'/'+f.devicesLength+')') || ''}</th>`
} }
break; break;
case 'SourceName': case 'SourceName':
@ -1296,8 +1269,6 @@ module.exports = function (app, opts) {
break; break;
} }
} }
} }
tableData += '</tr>' tableData += '</tr>'
alarmContent += tableData alarmContent += tableData

Loading…
Cancel
Save