Browse Source

邮件优化

dev
wenlele 1 year ago
parent
commit
00d0adfef1
  1. 43
      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

43
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,8 +324,46 @@ 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 (s.externalPlatform) {
if (!corStrut) {
const factorList = await clickHouse.dataAlarm
.query(`select SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId = ${s.strucId}`)
.toPromise()
const project = await clickHouse.dataAlarm
.query(`select Project from sensors where PlatformStructureId =${s.strucId} limit 1 `)
.toPromise()
let fList = factorList.map(m => m.SafetyFactorTypeId)
let list = await clickHouse.dataAlarm
.query(
`select distinct FactorID, Name,Items,ItemNames from factors
where FactorID in (${[...fList, -1].join(',')})
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
})
}
} else {
if (!corStrut) { if (!corStrut) {
let nextFacor = [] let nextFacor = []
if (s.factorId) { if (s.factorId) {
@ -375,6 +414,8 @@ async function strucWithPomsProject (ctx) {
} }
} }
} }
}
} }
ctx.status = 200; ctx.status = 200;

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