diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index 8307737..5279241 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -353,11 +353,13 @@ async function confirmApiError(ctx) { //存最新动态 let dynamics = rslt.map(r => { return { - time: moment().format(), - alarmConfirmId: r.id + time: r.confirmTime, + alarmConfirmId: r.id, + projectCorrelationId: r.projectCorrelationId, + type: 4//告警确认 } }) - await models.AlarmConfirmLog.bulkCreate(dynamics); + await models.LatestDynamicList.bulkCreate(dynamics); ctx.status = 204; diff --git a/api/app/lib/controllers/console/index.js b/api/app/lib/controllers/console/index.js index 5fbe963..b12aabd 100644 --- a/api/app/lib/controllers/console/index.js +++ b/api/app/lib/controllers/console/index.js @@ -22,8 +22,16 @@ async function getWorkbench(ctx) { async function getProjectsInfo(ctx) { try { const { models } = ctx.fs.dc; - const { clickHouse } = ctx.app.fs - const { alarmId, limit, page } = ctx.query + const { clickHouse } = ctx.app.fs; + const { alarmId, limit, page, projectCorrelationId } = ctx.query; + const { userInfo } = ctx.fs.api; + let where = {} + if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) { + where.projectCorrelationId = { $in: userInfo.correlationProject } + } + if (projectCorrelationId) {//查指定项目,控制台全局切换 + where.projectCorrelationId = projectCorrelationId + } ctx.status = 200; ctx.body = [] } catch (error) { @@ -56,11 +64,11 @@ async function getBiAnalysis(ctx) { async function getLatestDynamic(ctx) { try { const { models } = ctx.fs.dc; - const { limit, page, projectCorrelationId } = ctx.query; + const { limit, page, projectCorrelationId, types } = ctx.query; const { userInfo } = ctx.fs.api; const { clickHouse } = ctx.app.fs; - let where = {} + let where = { type: { $in: types.split(',') } }//传类型选择 if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) { where.projectCorrelationId = { $in: userInfo.correlationProject } } diff --git a/api/app/lib/models/alarm_appear_record.js b/api/app/lib/models/alarm_appear_record.js index 5bf40d6..3a6dcfa 100644 --- a/api/app/lib/models/alarm_appear_record.js +++ b/api/app/lib/models/alarm_appear_record.js @@ -42,6 +42,15 @@ module.exports = dc => { primaryKey: false, field: "time", autoIncrement: false + }, + type: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "数据告警:data,设备告警:device,应用告警:application", + primaryKey: false, + field: "type", + autoIncrement: false } }, { tableName: "alarm_appear_record", diff --git a/api/app/lib/models/latest_dynamic_list.js b/api/app/lib/models/latest_dynamic_list.js index 65ac6cd..5b53051 100644 --- a/api/app/lib/models/latest_dynamic_list.js +++ b/api/app/lib/models/latest_dynamic_list.js @@ -60,6 +60,15 @@ module.exports = dc => { primaryKey: false, field: "project_correlation_id", autoIncrement: false + }, + type: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: '1:发现,2:通知,3:处置,4:确认', + primaryKey: false, + field: "type", + autoIncrement: false } }, { tableName: "latest_dynamic_list", diff --git a/api/app/lib/routes/console/index.js b/api/app/lib/routes/console/index.js index 17f6fe2..a9ccc58 100644 --- a/api/app/lib/routes/console/index.js +++ b/api/app/lib/routes/console/index.js @@ -18,6 +18,6 @@ module.exports = function (app, router, opts) { router.get('/user/:userId/bi/analysis', console.getBiAnalysis); //最新动态 - app.fs.api.logAttr['GET/user/:userId/latest/dynamic'] = { content: '查询最新动态', visible: false }; - router.get('/user/:userId/latest/dynamic', console.getLatestDynamic); + app.fs.api.logAttr['GET/latest/dynamic'] = { content: '查询最新动态', visible: false }; + router.get('/latest/dynamic', console.getLatestDynamic); };