From ac141a171e45c543bfed5a3596fbc1665c119ad5 Mon Sep 17 00:00:00 2001 From: wuqun Date: Wed, 16 Nov 2022 14:24:43 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E8=8E=B7=E5=8F=96=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=AF=BC=E5=87=BAexcel=E8=A1=A8=E5=A4=B4=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/app.js | 2 +- api/app/lib/controllers/alarm/data.js | 2 +- api/app/lib/controllers/alarm/video.js | 2 +- api/app/lib/utils/exportAlarmHeader.js | 12 ++++-------- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index 6010b7a..8e989df 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -375,7 +375,7 @@ async function exportAppAlarms(ctx, listRes) { let typeData = { element: "元素异常", apiError: "接口报错 ", timeout: "加载超时" } try { const { utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs; - let header = await getExportAlarmHeader(ctx, 'app'); + let header = await getExportAlarmHeader('app'); let exportData = [] for (let { dataValues: item } of listRes.rows) { let projectName = []; diff --git a/api/app/lib/controllers/alarm/data.js b/api/app/lib/controllers/alarm/data.js index 3aafbb9..7ad2046 100644 --- a/api/app/lib/controllers/alarm/data.js +++ b/api/app/lib/controllers/alarm/data.js @@ -242,7 +242,7 @@ async function getAlarmGroups(ctx) { async function exportDataAlarms(ctx, alarmList, groupId) { try { const { utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs; - let header = await getExportAlarmHeader(ctx, groupId); + let header = await getExportAlarmHeader(groupId); let alarmGroups = await getAlarmGroups(ctx); let ggroups = [] diff --git a/api/app/lib/controllers/alarm/video.js b/api/app/lib/controllers/alarm/video.js index e168d4d..b4ed366 100644 --- a/api/app/lib/controllers/alarm/video.js +++ b/api/app/lib/controllers/alarm/video.js @@ -286,7 +286,7 @@ async function exportVideoAlarms(ctx, alarmList) { const kindRes = await clickHouse.vcmp.query(` SELECT * FROM camera_kind `).toPromise() - let header = await getExportAlarmHeader(ctx, 'video'); + let header = await getExportAlarmHeader('video'); let exportData = [] for (let item of alarmList) { let projectNames = item.pomsProject.map(p => { diff --git a/api/app/lib/utils/exportAlarmHeader.js b/api/app/lib/utils/exportAlarmHeader.js index b8cdfa1..2f436a5 100644 --- a/api/app/lib/utils/exportAlarmHeader.js +++ b/api/app/lib/utils/exportAlarmHeader.js @@ -243,7 +243,7 @@ let header_app = [{ key: "confirmTime", }]; module.exports = function (app, opts) { - async function getExportAlarmHeader(ctx, type) { + async function getExportAlarmHeader(type) { try { let headerMap = { "1": headerZD,//数据中断 @@ -254,13 +254,9 @@ module.exports = function (app, opts) { app: header_app, } return headerMap[type] || [] - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + } catch (err) { + console.log(`获取告警导出表格表头失败, error: ${err}`); + } } return {