Browse Source

EM推送信息查询

dev
巴林闲侠 2 years ago
parent
commit
341c8358f6
  1. 60
      api/app/lib/controllers/push/config.js
  2. 2
      api/app/lib/models/alarm_push_config.js

60
api/app/lib/controllers/push/config.js

@ -9,22 +9,22 @@ async function list (ctx) {
const { utils: { anxinStrucIdRange, pomsProjectRange } } = ctx.app.fs
const { keyword, keywordTarget, alarmType, state, tactics, pomsProjectId } = ctx.query
let projectCorrelationWhere = {
del: false,
}
if (state == 'notYet') {
projectCorrelationWhere.pepProjectId = { $ne: null }
}
// let projectCorrelationWhere = {
// del: false,
// }
// if (state == 'notYet') {
// projectCorrelationWhere.pepProjectId = { $ne: null }
// }
let findOption = {
where: {
del: false
},
order: [['id', 'desc']],
include: [{
model: models.ProjectCorrelation,
where: projectCorrelationWhere,
required: true
}]
// includes: [{
// model: models.ProjectCorrelation,
// where: projectCorrelationWhere,
// required: true
// }]
}
let anxinStrucsRange = await anxinStrucIdRange({
@ -48,7 +48,7 @@ async function list (ctx) {
ctx, pepProjectId: pomsProjectId, keywordTarget, keyword
})
let pomsProjectIds = pomsProjectRes.map(p => p.id)
findOption.where.pomsProjectId = { $in: pomsProjectIds }
findOption.where.pomsProjectId = { $overlap: pomsProjectIds }
if (alarmType) {
findOption.where.alarmType = { $contains: [alarmType] }
@ -65,6 +65,7 @@ async function list (ctx) {
}
const listRes = await models.AlarmPushConfig.findAll(findOption)
// const listRes = await models.AlarmPushConfig.findAll({})
let allStrucIds = new Set()
let allConfigId = []
let allReceiverIds = new Set()
@ -104,17 +105,28 @@ async function list (ctx) {
let returnD = []
for (let { dataValues: p } of listRes) {
// 查对应的 poms 绑定的结构物绑定关系
const corBind = pomsProjectRes.find(ppj => ppj.id == p.pomsProjectId)
if (corBind.pepProjectId) {
if (state == 'notYet') {
if (corBind.pepProject && p.timeType.some(pt => pt == corBind.pepProject.constructionStatusId)) {
continue
}
} else if (state == 'takeEffect') {
if (!corBind.pepProject || !p.timeType.some(pt => pt == corBind.pepProject.constructionStatusId)) {
continue
const corBinds = pomsProjectRes.filter(ppj => p.pomsProjectId.includes(ppj.id))
let filterBinds = []
for (let corBind of corBinds) {
if (corBind.pepProjectId) {
if (state == 'notYet') {
if (corBind.pepProject && p.timeType.some(pt => pt == corBind.pepProject.constructionStatusId)) {
continue
}
} else if (state == 'takeEffect') {
if (!corBind.pepProject || !p.timeType.some(pt => pt == corBind.pepProject.constructionStatusId)) {
continue
}
}
} else if(state == 'notYet'){
continue
}
filterBinds.push(corBind)
}
if (!filterBinds.length) {
continue
}
// 结构物信息
@ -129,7 +141,7 @@ async function list (ctx) {
returnStruc.push({
id: sid,
name: structure.name,
unbind: !anxinStrucSeen || !corBind.anxinProjectId.includes(anxinStrucSeen.projectId)
unbind: !anxinStrucSeen || corBinds.every(corBinds => !corBinds.anxinProjectId.includes(anxinStrucSeen.projectId))
})
} else {
// 这个结构物已删
@ -142,7 +154,7 @@ async function list (ctx) {
const corReceiver = userRes.filter(u => p.receiverPepUserId.some(prId => u.id == prId))
returnD.push({
...p,
pomsProject: corBind,
pomsProject: corBinds,
structure: returnStruc,
pushCount: corLogCount ? corLogCount.dataValues.count : 0,
receiverPepUser: corReceiver
@ -169,7 +181,7 @@ async function edit (ctx) {
let storageData = {
name, pomsProjectId, alarmType, receiverPepUserId, timeType, disable,
strucId, tactics, tacticsParams,alarmSubType
strucId, tactics, tacticsParams, alarmSubType
}
let repeatOption = {

2
api/app/lib/models/alarm_push_config.js

@ -25,7 +25,7 @@ module.exports = dc => {
autoIncrement: false
},
pomsProjectId: {
type: DataTypes.INTEGER,
type: DataTypes.ARRAY(DataTypes.INTEGER),
allowNull: false,
defaultValue: null,
comment: null,

Loading…
Cancel
Save