api history report
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
const { getHistoryAlarmDb } = require('../db/history_value.db');
|
||||
const { getHistoryAlarmDb, getHistoryEventDb, checkTableNamedDb, getHistoryValueReportDb, getHistoryValueReportPivotDb, getHistoryValueTrendingPivotDb } = require('../db/history_value.db');
|
||||
const { getSubSectionByIdDb } = require('../db/plant_sub_section.db');
|
||||
const { ErrorHandler } = require('../helpers/error');
|
||||
|
||||
class HistoryValue {
|
||||
// Get all devices
|
||||
|
||||
static async getAllHistoryAlarm(param) {
|
||||
try {
|
||||
const results = await getHistoryAlarmDb(param);
|
||||
@@ -15,6 +16,85 @@ class HistoryValue {
|
||||
throw new ErrorHandler(error.statusCode, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async getAllHistoryEvent(param) {
|
||||
try {
|
||||
const results = await getHistoryEventDb(param);
|
||||
|
||||
results.data.map(element => {
|
||||
});
|
||||
|
||||
return results
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async getHistoryValueReport(param) {
|
||||
try {
|
||||
|
||||
const plantSubSection = await getSubSectionByIdDb(param.plant_sub_section_id);
|
||||
|
||||
if (plantSubSection.length < 1) throw new ErrorHandler(404, 'Plant sub section not found');
|
||||
|
||||
const tabelExist = await checkTableNamedDb(plantSubSection[0]?.table_name_value);
|
||||
|
||||
if (tabelExist.length < 1) throw new ErrorHandler(404, 'Value not found');
|
||||
|
||||
const results = await getHistoryValueReportDb(tabelExist[0]?.TABLE_NAME, param);
|
||||
|
||||
results.data.map(element => {
|
||||
});
|
||||
|
||||
return results
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async getHistoryValueReportPivot(param) {
|
||||
try {
|
||||
|
||||
const plantSubSection = await getSubSectionByIdDb(param.plant_sub_section_id);
|
||||
|
||||
if (plantSubSection.length < 1) throw new ErrorHandler(404, 'Plant sub section not found');
|
||||
|
||||
const tabelExist = await checkTableNamedDb(plantSubSection[0]?.table_name_value);
|
||||
|
||||
if (tabelExist.length < 1) throw new ErrorHandler(404, 'Value not found');
|
||||
|
||||
const results = await getHistoryValueReportPivotDb(tabelExist[0]?.TABLE_NAME, param);
|
||||
|
||||
results.data.map(element => {
|
||||
});
|
||||
|
||||
return results
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async getHistoryValueTrendingPivot(param) {
|
||||
try {
|
||||
|
||||
const plantSubSection = await getSubSectionByIdDb(param.plant_sub_section_id);
|
||||
|
||||
if (plantSubSection.length < 1) throw new ErrorHandler(404, 'Plant sub section not found');
|
||||
|
||||
const tabelExist = await checkTableNamedDb(plantSubSection[0]?.table_name_value);
|
||||
|
||||
if (tabelExist.length < 1) throw new ErrorHandler(404, 'Value not found');
|
||||
|
||||
const results = await getHistoryValueTrendingPivotDb(tabelExist[0]?.TABLE_NAME, param);
|
||||
|
||||
results.data.map(element => {
|
||||
});
|
||||
|
||||
return results
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HistoryValue;
|
||||
|
||||
Reference in New Issue
Block a user