巴林闲侠 2 years ago
parent
commit
f894b93d27
  1. 2
      api/app/lib/controllers/alarm/app.js
  2. 2
      api/app/lib/controllers/alarm/data.js
  3. 2
      api/app/lib/controllers/alarm/video.js
  4. 10
      api/app/lib/utils/exportAlarmHeader.js

2
api/app/lib/controllers/alarm/app.js

@ -375,7 +375,7 @@ async function exportAppAlarms(ctx, listRes) {
let typeData = { element: "元素异常", apiError: "接口报错 ", timeout: "加载超时" } let typeData = { element: "元素异常", apiError: "接口报错 ", timeout: "加载超时" }
try { try {
const { utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs; const { utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs;
let header = await getExportAlarmHeader(ctx, 'app'); let header = await getExportAlarmHeader('app');
let exportData = [] let exportData = []
for (let { dataValues: item } of listRes.rows) { for (let { dataValues: item } of listRes.rows) {
let projectName = []; let projectName = [];

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

@ -242,7 +242,7 @@ async function getAlarmGroups(ctx) {
async function exportDataAlarms(ctx, alarmList, groupId) { async function exportDataAlarms(ctx, alarmList, groupId) {
try { try {
const { utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs; const { utils: { simpleExcelDown, getExportAlarmHeader } } = ctx.app.fs;
let header = await getExportAlarmHeader(ctx, groupId); let header = await getExportAlarmHeader(groupId);
let alarmGroups = await getAlarmGroups(ctx); let alarmGroups = await getAlarmGroups(ctx);
let ggroups = [] let ggroups = []

2
api/app/lib/controllers/alarm/video.js

@ -286,7 +286,7 @@ async function exportVideoAlarms(ctx, alarmList) {
const kindRes = await clickHouse.vcmp.query(` const kindRes = await clickHouse.vcmp.query(`
SELECT * FROM camera_kind SELECT * FROM camera_kind
`).toPromise() `).toPromise()
let header = await getExportAlarmHeader(ctx, 'video'); let header = await getExportAlarmHeader('video');
let exportData = [] let exportData = []
for (let item of alarmList) { for (let item of alarmList) {
let projectNames = item.pomsProject.map(p => { let projectNames = item.pomsProject.map(p => {

10
api/app/lib/utils/exportAlarmHeader.js

@ -243,7 +243,7 @@ let header_app = [{
key: "confirmTime", key: "confirmTime",
}]; }];
module.exports = function (app, opts) { module.exports = function (app, opts) {
async function getExportAlarmHeader(ctx, type) { async function getExportAlarmHeader(type) {
try { try {
let headerMap = { let headerMap = {
"1": headerZD,//数据中断 "1": headerZD,//数据中断
@ -254,12 +254,8 @@ module.exports = function (app, opts) {
app: header_app, app: header_app,
} }
return headerMap[type] || [] return headerMap[type] || []
} catch (error) { } catch (err) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); console.log(`获取告警导出表格表头失败, error: ${err}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
} }
} }

Loading…
Cancel
Save