diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 50337d9..25cf3aa 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -20,6 +20,7 @@ // 测试 "-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS", "-k node35:6667,node36:6667,node37:6667", + "--iotaProxy http://10.8.30.157:17007", "--redisHost 10.8.30.112", "--redisPort 6379", "--axyApiUrl http://127.0.0.1:4100", @@ -63,7 +64,7 @@ "--confirmAlarmAnxinUserId 1", "--vcmpAppId 5048b08d-c449-4d7f-b1ec-f741012aefe8", - "--vcmpAppSecret 5ba8c0ab-9fbd-4f07-9817-c48017c3cbad" + "--vcmpAppSecret 5ba8c0ab-9fbd-4f07-9817-c48017c3cbad", ] }, { diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index 4e8ad77..8e4ad8c 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -40,10 +40,10 @@ async function list (ctx) { ctx, pepProjectId, keywordTarget, keyword }) let whereOption = [] - // TODO: 1 开发临时增加 + // ! 1 开发临时增加 if (anxinStruc.length) { const anxinStrucIds = anxinStruc.map(a => a.strucId) - // TODO: 开发临时注释 + // ! 开发临时注释 whereOption.push(`alarms.StructureId IN (${anxinStrucIds.join(",")})`) if (groupId) { @@ -109,6 +109,7 @@ async function list (ctx) { ${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} `).toPromise(); + // TODO lukai 说这里要加也不知道啥时候加 // , // ${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) || {}); - // if (corConfirmedData.AlarmState && corConfirmedData.AlarmState > 2) { - - // } else { - // corConfirmedData = {} - // } ar.confirmedContent = corConfirmedData.Content || null ar.confirmedTime = corConfirmedData.Time || null @@ -203,13 +199,24 @@ async function detail (ctx) { try { const { models } = ctx.fs.dc; const { clickHouse } = ctx.app.fs - const { alarmId } = ctx.query + const { alarmId, limit, page } = ctx.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() - ctx.status = 200; + // ctx.body = { + // count: count[0].count, + // rows: detailRes + // } ctx.body = detailRes } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); diff --git a/api/config.js b/api/config.js index 83caaf4..a7badf7 100644 --- a/api/config.js +++ b/api/config.js @@ -13,6 +13,8 @@ args.option(['g', 'pg'], 'postgre 服务 URL'); args.option(['f', 'fileHost'], '文件中心本地化存储: WebApi 服务器地址(必填), 该服务器提供文件上传Web服务'); args.option(['k', 'kafka'], 'kafka 服务 URL'); +args.option('iotaProxy', '以太代理') + args.option('redisHost', 'redisHost'); args.option('redisPort', 'redisPort'); args.option('redisPswd', 'redisPassword'); @@ -56,6 +58,9 @@ const LOCAL_SVR_ORIGIN = process.env.LOCAL_SVR_ORIGIN || flags.fileHost; // kafka const ANXINCLOUD_KAFKA_BROKERS = process.env.ANXINCLOUD_KAFKA_BROKERS || flags.kafka; +// 以太代理 +const IOT_PROXY = process.env.IOT_PROXY || flags.iotaProxy; + // Redis 参数 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 端口 @@ -195,6 +200,9 @@ const product = { }, { name: 'iotAuthRequest', root: API_IOT_AUTH + }, { + name: 'iotRequest', + root: IOT_PROXY + '/_iota_api' }, { name: 'godRequest', root: GOD_URL,