~/Config/AppNodeJs/{owenrId}-plugins/{mkey}/{field}.js
var fnDataCamcel = require('../../Plugins/fn-common-data-camcel.js');
module.exports = function (callback, result, params, args) {
let argParams = JSON.parse(result);
let paramsT = JSON.parse(params);
if (paramsT._ori === "init") {
//最初数据
callback(null, argParams);
} else if (paramsT._ori === "convert") {
//转换后数据
if (argParams.Children) {
fnDataCamcel.mergeBsObject(argParams.Data, argParams.Children);
delete argParams.Children;
}
//扩展代码处理 end
if (paramsT["_nodejs"] !== "common-data-under") {
fnDataCamcel.toLowerCamcelByObject(argParams, paramsT["_null"] !== "true");
}
delete argParams.schema;
delete argParams.dimension;
if (argParams.children) {
fnDataCamcel.mergeBsObject(argParams.data, argParams.children);
delete argParams.children;
}
callback(null, argParams);
} else if (paramsT._dataFromType === "api") {
//api
let lastData = {
code: 0,
success: true
};
const dateKeys = Object.keys(argParams.data);
if (paramsT._dataFromType === "api" && argParams['error_code'] === '00' && dateKeys.length > 0) {
//const lastKey = dateKeys[dateKeys.length - 1]
//let item = argParams.data[lastKey];
//let spaceId = paramsT.spaceId;
//lastData.data = {
// "data_date": {
// name: dayjs.unix(lastKey).format('YYYY-MM-DD HH:mm:ss'),
// value: dayjs.unix(lastKey).format('YYYY-MM-DDTHH:mm:ss')
// }
//};
//if (paramsT["_nodejs"] !== "common-data-under") {
// fnDataCamcel.toLowerCamcelByObject(lastData, paramsT["_null"] !== "true");
//}
//lastData.t = argParams.data;
//callback(null, lastData);
callback(null, argParams);
} else if (paramsT._dataFromType === "api") {
//lastData.data = { }
//if (paramsT["_nodejs"] !== "common-data-under") {
// fnDataCamcel.toLowerCamcelByObject(lastData, paramsT["_null"] !== "true");
//}
//callback(null, lastData);
callback(null, argParams);
} else {
callback(null, argParams);
}
} else if (paramsT._dataFromType === "configFile") {
//静态数据
callback(null, argParams);
} else if (paramsT._dataFromType === "merge") {
//合并组合
callback(null, argParams);
} else if (argParams.Success === true) {
if (argParams.Children) {
fnDataCamcel.mergeBsObject(argParams.Data, argParams.Children);
delete argParams.Children;
}
//const dataT = argParams.Data;
//let lastData = {
// code: 0,
// success: true
//};
//if (dataT.power_used) {
// dataT.else_used = parseFloat(((dataT.power_used || 0) - (dataT.ups_used || 0) - (dataT.cooling_used || 0)).toFixed(2));
//}
//lastData.data = { }
//argParams = lastData;
//扩展代码处理 end
if (paramsT["_nodejs"] !== "common-data-under") {
fnDataCamcel.toLowerCamcelByObject(argParams, paramsT["_null"] !== "true");
}
delete argParams.schema;
delete argParams.dimension;
if (argParams.children) {
fnDataCamcel.mergeBsObject(argParams.data, argParams.children);
delete argParams.children;
}
callback(null, argParams);
} else {
callback(null, argParams);
}
};
文档更新时间: 2021-08-22 08:00 作者:admin