Browse Source

告警详情分页

dev
巴林闲侠 2 years ago
parent
commit
f3807cb62b
  1. 3
      api/.vscode/launch.json
  2. 27
      api/app/lib/controllers/alarm/data.js
  3. 8
      api/config.js

3
api/.vscode/launch.json

@ -20,6 +20,7 @@
// //
"-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS", "-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS",
"-k node35:6667,node36:6667,node37:6667", "-k node35:6667,node36:6667,node37:6667",
"--iotaProxy http://10.8.30.157:17007",
"--redisHost 10.8.30.112", "--redisHost 10.8.30.112",
"--redisPort 6379", "--redisPort 6379",
"--axyApiUrl http://127.0.0.1:4100", "--axyApiUrl http://127.0.0.1:4100",
@ -63,7 +64,7 @@
"--confirmAlarmAnxinUserId 1", "--confirmAlarmAnxinUserId 1",
"--vcmpAppId 5048b08d-c449-4d7f-b1ec-f741012aefe8", "--vcmpAppId 5048b08d-c449-4d7f-b1ec-f741012aefe8",
"--vcmpAppSecret 5ba8c0ab-9fbd-4f07-9817-c48017c3cbad" "--vcmpAppSecret 5ba8c0ab-9fbd-4f07-9817-c48017c3cbad",
] ]
}, },
{ {

27
api/app/lib/controllers/alarm/data.js

@ -40,10 +40,10 @@ async function list (ctx) {
ctx, pepProjectId, keywordTarget, keyword ctx, pepProjectId, keywordTarget, keyword
}) })
let whereOption = [] let whereOption = []
// TODO: 1 开发临时增加 // ! 1 开发临时增加
if (anxinStruc.length) { if (anxinStruc.length) {
const anxinStrucIds = anxinStruc.map(a => a.strucId) const anxinStrucIds = anxinStruc.map(a => a.strucId)
// TODO: 开发临时注释 // ! 开发临时注释
whereOption.push(`alarms.StructureId IN (${anxinStrucIds.join(",")})`) whereOption.push(`alarms.StructureId IN (${anxinStrucIds.join(",")})`)
if (groupId) { if (groupId) {
@ -109,6 +109,7 @@ async function list (ctx) {
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} ${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''}
`).toPromise(); `).toPromise();
// TODO lukai 说这里要加也不知道啥时候加
// , // ,
// ${anxinyun}.t_alarm_type.old_name AS alarmTypeOldName // ${anxinyun}.t_alarm_type.old_name AS alarmTypeOldName
@ -167,11 +168,6 @@ async function list (ctx) {
// 最新告警详情 - 确认信息 // 最新告警详情 - 确认信息
let corConfirmedData = (confirmedAlarmDetailMax.find(cdm => cdm.AlarmId == ar.AlarmId) || {}); let corConfirmedData = (confirmedAlarmDetailMax.find(cdm => cdm.AlarmId == ar.AlarmId) || {});
// if (corConfirmedData.AlarmState && corConfirmedData.AlarmState > 2) {
// } else {
// corConfirmedData = {}
// }
ar.confirmedContent = corConfirmedData.Content || null ar.confirmedContent = corConfirmedData.Content || null
ar.confirmedTime = corConfirmedData.Time || null ar.confirmedTime = corConfirmedData.Time || null
@ -203,13 +199,24 @@ async function detail (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { alarmId } = ctx.query const { alarmId, limit, page } = ctx.query
const detailRes = await clickHouse.dataAlarm.query(` const detailRes = await clickHouse.dataAlarm.query(`
SELECT * FROM alarm_details WHERE AlarmId = '${alarmId}' ORDER BY Time ASC SELECT * FROM alarm_details
WHERE AlarmId = '${alarmId}'
ORDER BY Time ASC
${limit ? 'LIMIT ' + limit : ''}
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''}
`).toPromise()
const count = await clickHouse.dataAlarm.query(`
SELECT count(*) AS count FROM alarm_details
WHERE AlarmId = '${alarmId}'
`).toPromise() `).toPromise()
ctx.status = 200; ctx.status = 200;
// ctx.body = {
// count: count[0].count,
// rows: detailRes
// }
ctx.body = detailRes ctx.body = detailRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);

8
api/config.js

@ -13,6 +13,8 @@ args.option(['g', 'pg'], 'postgre 服务 URL');
args.option(['f', 'fileHost'], '文件中心本地化存储: WebApi 服务器地址(必填), 该服务器提供文件上传Web服务'); args.option(['f', 'fileHost'], '文件中心本地化存储: WebApi 服务器地址(必填), 该服务器提供文件上传Web服务');
args.option(['k', 'kafka'], 'kafka 服务 URL'); args.option(['k', 'kafka'], 'kafka 服务 URL');
args.option('iotaProxy', '以太代理')
args.option('redisHost', 'redisHost'); args.option('redisHost', 'redisHost');
args.option('redisPort', 'redisPort'); args.option('redisPort', 'redisPort');
args.option('redisPswd', 'redisPassword'); args.option('redisPswd', 'redisPassword');
@ -56,6 +58,9 @@ const LOCAL_SVR_ORIGIN = process.env.LOCAL_SVR_ORIGIN || flags.fileHost;
// kafka // kafka
const ANXINCLOUD_KAFKA_BROKERS = process.env.ANXINCLOUD_KAFKA_BROKERS || flags.kafka; const ANXINCLOUD_KAFKA_BROKERS = process.env.ANXINCLOUD_KAFKA_BROKERS || flags.kafka;
// 以太代理
const IOT_PROXY = process.env.IOT_PROXY || flags.iotaProxy;
// Redis 参数 // Redis 参数
const IOTA_REDIS_SERVER_HOST = process.env.IOTA_REDIS_SERVER_HOST || flags.redisHost || "localhost";//redis IP const IOTA_REDIS_SERVER_HOST = process.env.IOTA_REDIS_SERVER_HOST || flags.redisHost || "localhost";//redis IP
const IOTA_REDIS_SERVER_PORT = process.env.IOTA_REDIS_SERVER_PORT || flags.redisPort || "6379";//redis 端口 const IOTA_REDIS_SERVER_PORT = process.env.IOTA_REDIS_SERVER_PORT || flags.redisPort || "6379";//redis 端口
@ -195,6 +200,9 @@ const product = {
}, { }, {
name: 'iotAuthRequest', name: 'iotAuthRequest',
root: API_IOT_AUTH root: API_IOT_AUTH
}, {
name: 'iotRequest',
root: IOT_PROXY + '/_iota_api'
}, { }, {
name: 'godRequest', name: 'godRequest',
root: GOD_URL, root: GOD_URL,

Loading…
Cancel
Save