diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index 1cf6684..6d97f7c 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -2,55 +2,6 @@ const moment = require('moment'); const { alarmList } = require('../alarm/video'); -//项目概览 -async function getProjectsInfo(ctx) { - try { - const { models } = ctx.fs.dc; - const { clickHouse, utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs - const { database: anxinyun } = clickHouse.anxinyun.opts.config - const { alarmId, limit, page, projectCorrelationId, pepProjectId, keywordTarget, keyword } = 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 - // } - let anxinStruc = await anxinStrucIdRange({ - ctx, pepProjectId, keywordTarget, keyword - }) - const anxinStrucIds = anxinStruc.map(a => a.strucId); - //先查全部的摄像头 - const videoList = anxinStrucIds.length ? await clickHouse.vcmp.query( - `select camera.id, - camera.name, - camera.serial_no from camera where camera.delete=false and camera.recycle_time is null - - LEFT JOIN ${anxinyun}.t_video_ipc AS anxinIpc - ON toString(anxinIpc.channel_no) = cameraAlarm.cameraChannelNo - AND anxinIpc.serial_no = cameraAlarm.cameraSerialNo - LEFT JOIN ${anxinyun}.t_structure AS anxinStruc - ON anxinStruc.id = anxinIpc.structure - AND anxinStruc.id IN (${anxinStrucIds.join(',')}) - LEFT JOIN ${anxinyun}.t_video_ipc_station AS anxinIpcStation - ON anxinIpcStation.ipc = anxinIpc.id - LEFT JOIN ${anxinyun}.t_sensor AS anxinStation - ON anxinStation.id = anxinIpcStation.station` - ).toPromise() : [] - - - ctx.status = 200; - ctx.body = [] - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } -} - //BI分析-数据 async function getDataAlarmsAggDay(ctx) { try { @@ -323,8 +274,6 @@ async function getLatestDynamic(ctx) { } module.exports = { - getProjectsInfo, - getDataAlarmsAggDay, getAppAlarmsAggDay, getVideoAlarmsAggDay, diff --git a/api/app/lib/routes/control/index.js b/api/app/lib/routes/control/index.js index b380664..23e4542 100644 --- a/api/app/lib/routes/control/index.js +++ b/api/app/lib/routes/control/index.js @@ -24,11 +24,6 @@ module.exports = function (app, router, opts) { router.get('/analysis/userlist', analysis.userlist); - - //项目概览 - app.fs.api.logAttr['GET/projects/info'] = { content: '查询项目概览', visible: false }; - router.get('/projects/info', csData.getProjectsInfo); - //BI分析模块 app.fs.api.logAttr['GET/data/alarms/agg/day'] = { content: '查询BI分析数据-数据', visible: false }; router.get('/data/alarms/agg/day', csData.getDataAlarmsAggDay); diff --git a/api/app/lib/schedule/alarms_handle_statistics.js b/api/app/lib/schedule/alarms_handle_statistics.js index 37097ae..7b02acd 100644 --- a/api/app/lib/schedule/alarms_handle_statistics.js +++ b/api/app/lib/schedule/alarms_handle_statistics.js @@ -149,6 +149,8 @@ module.exports = function (app, opts) { ON ${anxinyun}.t_structure.id = alarms.StructureId ${whereOption.length ? 'WHERE ' + whereOption.join(' AND ') : ''}` + console.log('开始查数据-数据-数据类告警---' + moment().format('YYYY-MM-DD HH:mm:ss')) + const alarmRes = await clickHouse.dataAlarm.query(` SELECT alarms.AlarmId AS AlarmId, @@ -157,6 +159,8 @@ module.exports = function (app, opts) { StartTime, EndTime ${alarmQueryOptionStr}`).toPromise(); + console.log('数据-数据-数据告警查询结束---' + moment().format('YYYY-MM-DD HH:mm:ss') + `---一共${alarmRes.length}条`) + const confirmedAlarm = alarmRes.filter(ar => ar.State && ar.State > 2).map(ar => "'" + ar.AlarmId + "'"); const confirmedAlarmDetailMax = confirmedAlarm.length ? await clickHouse.dataAlarm.query(` @@ -209,7 +213,11 @@ module.exports = function (app, opts) { findOption.where['$app->projectCorrelations.id$'] = { $in: pomsProjectIds } + + console.log('开始查应用-应用-应用告警---' + moment().format('YYYY-MM-DD HH:mm:ss')) const listRes = await models.AppAlarm.findAll(findOption) + console.log('应用-应用-应用告警查询结束---' + moment().format('YYYY-MM-DD HH:mm:ss') + `---一共${listRes.length}条`) + return listRes } catch (error) { console.error(error); @@ -222,6 +230,7 @@ module.exports = function (app, opts) { let start = moment().add(-1, 'year').format('YYYY-MM-DD HH:mm:ss');//最近一年 statusAlarmWhereOption.push(`camera_status_alarm.create_time >= '${start}'`) + console.log('开始查视频-视频-视频告警---' + moment().format('YYYY-MM-DD HH:mm:ss')) const alarmRes = anxinStrucIds.length ? await clickHouse.vcmp.query( ` SELECT @@ -276,6 +285,7 @@ module.exports = function (app, opts) { ON anxinIpcStation.ipc = anxinIpc.id `).toPromise() : [] + console.log('视频-视频-视频告警查询结束---' + moment().format('YYYY-MM-DD HH:mm:ss') + `---一共${alarmRes.length}条`) let returnD = [] let positionD = {} // 每个设备一个告警