Browse Source

邮件优化

dev
wenlele 1 year ago
parent
commit
00d0adfef1
  1. 117
      api/app/lib/controllers/project/index.js
  2. 7
      api/app/lib/schedule/alarms_push.js
  3. 2
      web/client/src/sections/service/components/pushModal.jsx

117
api/app/lib/controllers/project/index.js

@ -282,6 +282,7 @@ async function strucWithPomsProject (ctx) {
SELECT SELECT
t_structure.id AS strucId, t_structure.id AS strucId,
t_structure.name AS strucName, t_structure.name AS strucName,
t_structure.external_platform AS externalPlatform,
t_factor.id AS factorId, t_factor.id AS factorId,
t_factor.name AS factorName, t_factor.name AS factorName,
t_factor.proto AS factorProto, t_factor.proto AS factorProto,
@ -323,57 +324,97 @@ async function strucWithPomsProject (ctx) {
` `
).toPromise() : ).toPromise() :
[] []
for (let s of undelStrucRes) { for await (let s of undelStrucRes) {
let corStrut = undelStruc.find(us => us.id == s.strucId) let corStrut = undelStruc.find(us => us.id == s.strucId)
if (!corStrut) { if (s.externalPlatform) {
let nextFacor = [] if (!corStrut) {
if (s.factorId) { const factorList = await clickHouse.dataAlarm
let nextFactorItem = [] .query(`select SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId = ${s.strucId}`)
if (s.factorItemId) { .toPromise()
nextFactorItem.push({ const project = await clickHouse.dataAlarm
id: s.factorItemId, .query(`select Project from sensors where PlatformStructureId =${s.strucId} limit 1 `)
name: s.factorItemName, .toPromise()
})
} let fList = factorList.map(m => m.SafetyFactorTypeId)
nextFacor.push({ let list = await clickHouse.dataAlarm
id: s.factorId, .query(
name: s.factorName, `select distinct FactorID, Name,Items,ItemNames from factors
proto: s.factorProto, where FactorID in (${[...fList, -1].join(',')})
item: nextFactorItem, and Project = '${[...project, 0][0].Project}'
`
)
.toPromise() || []
let nextFacor = []
list.map(d => {
if (d.Name) {
nextFacor.push({
id: d.FactorID,
name: d.Name,
// proto: s.factorProto,
item: d.ItemNames && d.ItemNames.split(',').map(item => ({ id: item, name: item })) || [],
})
}
})
undelStruc.push({
id: s.strucId,
name: s.strucName,
factor: nextFacor
}) })
} }
undelStruc.push({
id: s.strucId,
name: s.strucName,
factor: nextFacor
})
} else { } else {
if (s.factorId) {
let corFactor = corStrut.factor.find(v => v.id == s.factorId) if (!corStrut) {
let nextFactorItem = null let nextFacor = []
if (s.factorItemId) { if (s.factorId) {
nextFactorItem = { let nextFactorItem = []
id: s.factorItemId, if (s.factorItemId) {
name: s.factorItemName, nextFactorItem.push({
} id: s.factorItemId,
} name: s.factorItemName,
if (corFactor) { })
if (!corFactor.item.some(fi => fi.id == s.factorItemId) && nextFactorItem) {
corFactor.item.push(nextFactorItem)
} }
} else { nextFacor.push({
corStrut.factor.push({
id: s.factorId, id: s.factorId,
name: s.factorName, name: s.factorName,
proto: s.factorProto, proto: s.factorProto,
item: nextFactorItem ? [{ item: nextFactorItem,
})
}
undelStruc.push({
id: s.strucId,
name: s.strucName,
factor: nextFacor
})
} else {
if (s.factorId) {
let corFactor = corStrut.factor.find(v => v.id == s.factorId)
let nextFactorItem = null
if (s.factorItemId) {
nextFactorItem = {
id: s.factorItemId, id: s.factorItemId,
name: s.factorItemName, name: s.factorItemName,
}] : [], }
}) }
if (corFactor) {
if (!corFactor.item.some(fi => fi.id == s.factorItemId) && nextFactorItem) {
corFactor.item.push(nextFactorItem)
}
} else {
corStrut.factor.push({
id: s.factorId,
name: s.factorName,
proto: s.factorProto,
item: nextFactorItem ? [{
id: s.factorItemId,
name: s.factorItemName,
}] : [],
})
}
} }
} }
} }
} }
} }

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

@ -247,6 +247,7 @@ module.exports = function (app, opts) {
let emailSubTitle = '' let emailSubTitle = ''
let dataAlarmOption = [] let dataAlarmOption = []
let dataAlarmOptionLocal=[]
let dataAlarmGroupOption = [] let dataAlarmGroupOption = []
let dataAlarmSubType = [] let dataAlarmSubType = []
let dataAlarms = [] let dataAlarms = []
@ -287,6 +288,7 @@ module.exports = function (app, opts) {
} else if (c.tactics == 'continue' || c.tactics == 'abnormal_rate') { } else if (c.tactics == 'continue' || c.tactics == 'abnormal_rate') {
// 新增的应该是上一个时间节点到上上个节点之间 // 新增的应该是上一个时间节点到上上个节点之间
dataAlarmOption.push(`StartTime <= '${pointTime}'`); dataAlarmOption.push(`StartTime <= '${pointTime}'`);
dataAlarmOptionLocal.push(`StartTime <= '${pointTime}'`);
appAlarmWhereOption.createTime = { $lte: pointTime } appAlarmWhereOption.createTime = { $lte: pointTime }
videoAlarmWhereOption.push(`camera_status_alarm.create_time <= '${pointTime}'`) videoAlarmWhereOption.push(`camera_status_alarm.create_time <= '${pointTime}'`)
// 新增的应该是上一个时间节点到上上个节点之间 // 新增的应该是上一个时间节点到上上个节点之间
@ -541,6 +543,7 @@ module.exports = function (app, opts) {
if (c.alarmSubType && dataAlarmSubType_.length) { if (c.alarmSubType && dataAlarmSubType_.length) {
dataAlarmSubType_.push(-1) dataAlarmSubType_.push(-1)
dataAlarmOption.push(`AlarmGroupUnit IN (${dataAlarmSubType_.join(',')})`) dataAlarmOption.push(`AlarmGroupUnit IN (${dataAlarmSubType_.join(',')})`)
dataAlarmOptionLocal.push(`AlarmGroupUnit IN (${dataAlarmSubType_.join(',')})`)
} }
//安心云 //安心云
dataAlarms = dataAlarms =
@ -1295,13 +1298,15 @@ module.exports = function (app, opts) {
FROM FROM
alarms alarms
WHERE WHERE
AlarmGroup IN (1,4,5)
AND
alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId, -1].join(',') alarms.StructureId In (${[...dataAlarmG1StructureId, ...dataAlarmStructureId, -1].join(',')
// 3025 // 3025
}) })
AND AND
alarms.State < 3 alarms.State < 3
${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} ${dataAlarmOptionLocal.length ? ' AND ' + dataAlarmOptionLocal.join(' AND ') : ''}
` `
).toPromise() || [] ).toPromise() || []

2
web/client/src/sections/service/components/pushModal.jsx

@ -346,7 +346,7 @@ function pushModal (props) {
key={u.name + index} key={u.name + index}
field={'factor' + u.id} field={'factor' + u.id}
style={{ width: 695 }} style={{ width: 695 }}
initValue={editObj?.pomsStrucFactorId ? editObj?.pomsStrucFactorId[u.id] : (factorItem || [])} initValue={editObj?.pomsStrucFactorId ? (editObj?.pomsStrucFactorId[u.id]?.filter(d => factorItem.includes(d)) || []) : (factorItem || [])}
direction='horizontal' direction='horizontal'
showClear showClear
> >

Loading…
Cancel
Save