Browse Source

EM推送信息查询

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

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

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

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

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

Loading…
Cancel
Save