[Frontend] 電表總計 baja的js檔
This commit is contained in:
parent
b3fe76e37e
commit
8c4a7ac85e
37
Frontend/js/n4js/electricmeterbaja.js
Normal file
37
Frontend/js/n4js/electricmeterbaja.js
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 取得電表總計資料 by baja
|
||||
* @param {any} devicePath
|
||||
* @param {any} timeType
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getElectricMeterTotalByBaja(devicePath, timeType, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log('transform:slot:/' + devicePath + '/History/' + timeType);
|
||||
baja.Ord.make('transform:slot:/' + devicePath + '/History/' + timeType).get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"timestamp":"' + record.get('timestamp') + '", "MP1":' + record.get('MP1') + '"}';
|
||||
else
|
||||
_ss += ',{"timestamp":"' + record.get('timestamp') + '", "MP1":' + record.get('MP1') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user