巴林闲侠 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: "加载超时" }
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 = [];

2
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 = []

2
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 => {

10
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,12 +254,8 @@ 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}`);
}
}

Loading…
Cancel
Save