[Frontend][系統監控] 電梯模型更換 | [儀錶板] 即時告警點位訂閱程序建置 | 柱狀圖 baja 資料串接 | 左方 3d 圖 Size 調整 | 即時功率 baja 串接 | [baja] 取值 輸出程序調整

This commit is contained in:
dev01 2022-12-05 18:45:24 +08:00
parent 9aa7efcb6d
commit a57e40bf44
13 changed files with 37462 additions and 517 deletions

View File

@ -1,7 +1,10 @@
<main id="js-page-content" role="main" class="page-content"> <main id="js-page-content" role="main" class="page-content">
<div class="row"> <div class="row">
<div class="col-sm-12 col-xl-4"> <div class="col-sm-12 col-xl-4 poisition-relative">
<div id="forgeViewer"></div> <!-- <img src="img/clouds.png" class="img-fluid" style="min-height: 520px;"> -->
<div id="forgeViewer" class="position-absolute" style="width:96%;height:96%;"></div>
</div> </div>
<div class="col-sm-12 col-xl-4"> <div class="col-sm-12 col-xl-4">
<div class="row"> <div class="row">
@ -28,16 +31,16 @@
</div> </div>
</div> </div>
<div class="col-lg-12"> <div class="col-lg-12">
<div id="panel-2" class="panel panel-locked" data-panel-sortable data-panel-collapsed data-panel-close> <div id="panel-2" class="panel" data-panel-sortable data-panel-collapsed data-panel-close>
<div class="panel-hdr"> <div class="panel-hdr">
<h2> <h2>
昨日/今日用電比較 昨日/今日用電比較
</h2> </h2>
</div> </div>
<div class="panel-container show"> <div class="panel-container show">
<div class="panel-content poisition-relative" style="min-height: 346.84px;"> <div class="panel-content poisition-relative">
<div class="p-1 position-absolute pos-right pos-top mt-3 mr-3 z-index-cloud d-flex align-items-center justify-content-center"> <div class="p-1 position-absolute pos-right pos-top mt-3 mr-3 z-index-cloud d-flex align-items-center justify-content-center">
<div class="border-faded border-top-0 border-left-0 border-bottom-0 py-2 pr-4 mr-3 hidden-sm-down"> <!--<div class="border-faded border-top-0 border-left-0 border-bottom-0 py-2 pr-4 mr-3 hidden-sm-down">
<div class="text-right fw-500 l-h-n d-flex flex-column"> <div class="text-right fw-500 l-h-n d-flex flex-column">
<div class="h3 m-0 d-flex align-items-center justify-content-end"> <div class="h3 m-0 d-flex align-items-center justify-content-end">
<div class='icon-stack mr-2'> <div class='icon-stack mr-2'>
@ -54,9 +57,11 @@
<div class="js-easy-pie-chart color-success-400 position-relative position-absolute pos-left pos-right pos-top pos-bottom d-flex align-items-center justify-content-center" data-percent="65" data-piesize="60" data-linewidth="5" data-scalelength="1" data-scalecolor="#fff"> <div class="js-easy-pie-chart color-success-400 position-relative position-absolute pos-left pos-right pos-top pos-bottom d-flex align-items-center justify-content-center" data-percent="65" data-piesize="60" data-linewidth="5" data-scalelength="1" data-scalecolor="#fff">
<div class="position-absolute pos-top pos-left pos-right pos-bottom d-flex align-items-center justify-content-center fw-500 fs-xl text-dark">78%</div> <div class="position-absolute pos-top pos-left pos-right pos-bottom d-flex align-items-center justify-content-center fw-500 fs-xl text-dark">78%</div>
</div> </div>
</div> </div>-->
</div>
<div style="width:100%; min-height:300px;">
<canvas class="chart" id="eveDayElecChart"></canvas>
</div> </div>
<div id="flot-area" style="width:100%; height:300px;"></div>
</div> </div>
</div> </div>
</div> </div>
@ -88,7 +93,7 @@
</div> </div>
</div> </div>
<div class="col-lg-12"> <div class="col-lg-12">
<div id="panel-3" class="panel panel-locked" data-panel-sortable data-panel-collapsed data-panel-close> <div id="panel-3" class="panel" data-panel-sortable data-panel-collapsed data-panel-close>
<div class="panel-hdr"> <div class="panel-hdr">
<h2> <h2>
本週/上週用電比較 本週/上週用電比較
@ -96,7 +101,7 @@
</div> </div>
<div class="panel-container show"> <div class="panel-container show">
<div class="panel-content poisition-relative"> <div class="panel-content poisition-relative">
<div class="pb-5 pt-3"> <!--<div class="pb-5 pt-3">
<div class="row"> <div class="row">
<div class="col-6 col-xl-3 d-sm-flex align-items-center"> <div class="col-6 col-xl-3 d-sm-flex align-items-center">
<div class="p-2 mr-3 bg-info-200 rounded"> <div class="p-2 mr-3 bg-info-200 rounded">
@ -135,8 +140,11 @@
</div> </div>
</div> </div>
</div> </div>
</div>-->
<div style="width:100%; min-height:300px;">
<canvas class="chart" id="eveWeekElecChart"></canvas>
</div> </div>
<div id="flotVisit" style="width:100%; height:208px;"></div>
</div> </div>
</div> </div>
</div> </div>
@ -155,7 +163,7 @@
<div class="col-sm-12 col-lg-4"> <div class="col-sm-12 col-lg-4">
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">
<div id="panel-3" class="panel panel-locked" data-panel-sortable data-panel-collapsed data-panel-close> <div id="panel-3" class="panel" data-panel-sortable data-panel-collapsed data-panel-close>
<div class="panel-hdr"> <div class="panel-hdr">
<h2> <h2>
異常狀態 異常狀態
@ -189,7 +197,7 @@
</div> </div>
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<div id="panel-3" class="panel panel-locked" data-panel-sortable data-panel-collapsed data-panel-close> <div id="panel-3" class="panel" data-panel-sortable data-panel-collapsed data-panel-close>
<div class="panel-hdr"> <div class="panel-hdr">
<h2> <h2>
工單進度 工單進度
@ -233,460 +241,51 @@
<script> <script>
/* defined datas */
var dataTargetProfit = [
[1354586000000, 153],
[1364587000000, 658],
[1374588000000, 198],
[1384589000000, 663],
[1394590000000, 801],
[1404591000000, 1080],
[1414592000000, 353],
[1424593000000, 749],
[1434594000000, 523],
[1444595000000, 258],
[1454596000000, 688],
[1464597000000, 364]
]
var dataProfit = [
[1354586000000, 53],
[1364587000000, 65],
[1374588000000, 98],
[1384589000000, 83],
[1394590000000, 980],
[1404591000000, 808],
[1414592000000, 720],
[1424593000000, 674],
[1434594000000, 23],
[1444595000000, 79],
[1454596000000, 88],
[1464597000000, 36]
]
var dataSignups = [
[1354586000000, 647],
[1364587000000, 435],
[1374588000000, 784],
[1384589000000, 346],
[1394590000000, 487],
[1404591000000, 463],
[1414592000000, 479],
[1424593000000, 236],
[1434594000000, 843],
[1444595000000, 657],
[1454596000000, 241],
[1464597000000, 341]
]
var dataSet1 = [
[0, 10],
[100, 8],
[200, 7],
[300, 5],
[400, 4],
[500, 6],
[600, 3],
[700, 2]
];
var dataSet2 = [
[0, 9],
[100, 6],
[200, 5],
[300, 3],
[400, 3],
[500, 5],
[600, 2],
[700, 1]
];
var tarElePath = ''; var tarElePath = '';
var sysSubList = [];
$(document).ready(function () { $(document).ready(function () {
show3DModel(); show3DModel();
getSubList(); getSubList();
getFirstEletric(); getFirstEletric();
/* init datatables */
$('#dt-basic-example').dataTable(
{
responsive: true,
dom: "<'row mb-3'<'col-sm-12 col-md-6 d-flex align-items-center justify-content-start'f><'col-sm-12 col-md-6 d-flex align-items-center justify-content-end'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
buttons: [
{
extend: 'colvis',
text: 'Column Visibility',
titleAttr: 'Col visibility',
className: 'btn-outline-default'
},
{
extend: 'csvHtml5',
text: 'CSV',
titleAttr: 'Generate CSV',
className: 'btn-outline-default'
},
{
extend: 'copyHtml5',
text: 'Copy',
titleAttr: 'Copy to clipboard',
className: 'btn-outline-default'
},
{
extend: 'print',
text: '<i class="fal fa-print"></i>',
titleAttr: 'Print Table',
className: 'btn-outline-default'
}
],
columnDefs: [
{
targets: -1,
title: '',
orderable: false,
render: function (data, type, full, meta) {
/*
-- ES6
-- convert using https://babeljs.io online transpiler
return `
<a href='javascript:void(0);' class='btn btn-sm btn-icon btn-outline-danger rounded-circle mr-1' title='Delete Record'>
<i class="fal fa-times"></i>
</a>
<div class='dropdown d-inline-block dropleft '>
<a href='#'' class='btn btn-sm btn-icon btn-outline-primary rounded-circle shadow-0' data-toggle='dropdown' aria-expanded='true' title='More options'>
<i class="fal fa-ellipsis-v"></i>
</a>
<div class='dropdown-menu'>
<a class='dropdown-item' href='javascript:void(0);'>Change Status</a>
<a class='dropdown-item' href='javascript:void(0);'>Generate Report</a>
</div>
</div>`;
ES5 example below:
*/
return "\n\t\t\t\t\t\t<a href='javascript:void(0);' class='btn btn-sm btn-icon btn-outline-danger rounded-circle mr-1' title='Delete Record'>\n\t\t\t\t\t\t\t<i class=\"fal fa-times\"></i>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t<div class='dropdown d-inline-block dropleft'>\n\t\t\t\t\t\t\t<a href='#'' class='btn btn-sm btn-icon btn-outline-primary rounded-circle shadow-0' data-toggle='dropdown' aria-expanded='true' title='More options'>\n\t\t\t\t\t\t\t\t<i class=\"fal fa-ellipsis-v\"></i>\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t<div class='dropdown-menu'>\n\t\t\t\t\t\t\t\t<a class='dropdown-item' href='javascript:void(0);'>Change Status</a>\n\t\t\t\t\t\t\t\t<a class='dropdown-item' href='javascript:void(0);'>Generate Report</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>";
},
},
]
});
/* flot toggle example */
var flot_toggle = function () {
var data = [
{
label: "Target Profit",
data: dataTargetProfit,
color: color.info._400,
bars:
{
show: true,
align: "center",
barWidth: 30 * 30 * 60 * 1000 * 80,
lineWidth: 0,
/*fillColor: {
colors: [color.primary._500, color.primary._900]
},*/
fillColor:
{
colors: [
{
opacity: 0.9
},
{
opacity: 0.1
}]
}
},
highlightColor: 'rgba(255,255,255,0.3)',
shadowSize: 0
},
{
label: "Actual Profit",
data: dataProfit,
color: color.warning._500,
lines:
{
show: true,
lineWidth: 2
},
shadowSize: 0,
points:
{
show: true
}
},
{
label: "User Signups",
data: dataSignups,
color: color.success._500,
lines:
{
show: true,
lineWidth: 2
},
shadowSize: 0,
points:
{
show: true
}
}]
var options = {
grid:
{
hoverable: true,
clickable: true,
tickColor: 'rgba(0,0,0,0.05)',
borderWidth: 1,
borderColor: 'rgba(0,0,0,0.05)'
},
tooltip: true,
tooltipOpts:
{
cssClass: 'tooltip-inner',
defaultTheme: false
},
xaxis:
{
mode: "time",
tickColor: 'rgba(0,0,0,0.05)',
},
yaxes:
{
tickColor: 'rgba(0,0,0,0.05)',
tickFormatter: function (val, axis) {
return "$" + val;
},
max: 1200
}
};
var plot2 = null;
function plotNow() {
var d = [];
$("#js-checkbox-toggles").find(':checkbox').each(function () {
if ($(this).is(':checked')) {
d.push(data[$(this).attr("name").substr(4, 1)]);
}
});
if (d.length > 0) {
if (plot2) {
plot2.setData(d);
plot2.draw();
}
else {
plot2 = $.plot($("#flot-toggles"), d, options);
}
}
};
$("#js-checkbox-toggles").find(':checkbox').on('change', function () {
plotNow();
});
plotNow()
}
flot_toggle();
/* flot toggle example -- end*/
/* flot area */
var flotArea = $.plot($('#flot-area'), [
{
data: dataSet1,
label: 'New Customer',
color: color.success._200
},
{
data: dataSet2,
label: 'Returning Customer',
color: color.info._200
}],
{
series:
{
lines:
{
show: true,
lineWidth: 2,
fill: true,
fillColor:
{
colors: [
{
opacity: 0
},
{
opacity: 0.5
}]
}
},
shadowSize: 0
},
points:
{
show: true,
},
legend:
{
noColumns: 1,
position: 'nw'
},
grid:
{
hoverable: true,
clickable: true,
borderColor: '#ddd',
tickColor: 'rgba(0,0,0,0.05)',
aboveData: true,
borderWidth: 0,
labelMargin: 5,
backgroundColor: 'transparent'
},
yaxis:
{
tickLength: 1,
min: 0,
max: 15,
color: '#eee',
tickColor: 'rgba(0,0,0,0.05)',
font:
{
size: 0,
color: '#999'
}
},
xaxis:
{
tickLength: 1,
color: '#eee',
tickColor: 'rgba(0,0,0,0.05)',
font:
{
size: 10,
color: '#999'
}
}
});
/* flot area -- end */
var flotVisit = $.plot('#flotVisit', [
{
data: [
[3, 0],
[4, 1],
[5, 3],
[6, 3],
[7, 10],
[8, 11],
[9, 12],
[10, 9],
[11, 12],
[12, 8],
[13, 5]
],
color: color.success._200
},
{
data: [
[1, 0],
[2, 0],
[3, 1],
[4, 2],
[5, 2],
[6, 5],
[7, 8],
[8, 12],
[9, 9],
[10, 11],
[11, 5]
],
color: color.info._200
}],
{
series:
{
shadowSize: 0,
lines:
{
show: true,
lineWidth: 2,
fill: true,
fillColor:
{
colors: [
{
opacity: 0
},
{
opacity: 0.12
}]
}
}
},
grid:
{
borderWidth: 0
},
yaxis:
{
min: 0,
max: 15,
tickColor: 'rgba(0,0,0,0.05)',
ticks: [
[0, ''],
[5, '100K'],
[10, '200K'],
[15, '300K']
],
font:
{
color: '#444',
size: 10
}
},
xaxis:
{
tickColor: 'rgba(0,0,0,0.05)',
ticks: [
[2, '2am'],
[3, '3am'],
[4, '4am'],
[5, '5am'],
[6, '6am'],
[7, '7am'],
[8, '8am'],
[9, '9am'],
[10, '1pm'],
[11, '2pm'],
[12, '3pm'],
[13, '4pm']
],
font:
{
color: '#999',
size: 9
}
}
});
}); });
function goElectricMeter() { // 從數字週數轉為中文週數
pageAct.sysMainTag = $('#subSysBtnE4').data("subSysObj").main_system_tag; function dayToChiDay(num) {
pageAct.sysSubTag = $('#subSysBtnE4').data("subSysObj").sub_system_tag; let chiDay = ["週日", "週一", "週二", "週三", "週四", "週五", "週六"];
pageAct.sysSubName = $('#subSysBtnE4').data("subSysObj").full_name; return chiDay[num];
pageAct.sysSubObj = $('#subSysBtnE4').data("subSysObj");
$("#js-page-content").load("_sysMonAll.html", loadCallback);
} }
// 取得現在或前後時間,輸出單位依據 type
function getTimeByType(type = null, cal = 0) {
let now = new Date();
return strToDate(now, type, cal);
}
// 取得某當下時間或前後時間,輸出單位依據 type
function strToDate(text, type = null,cal = 0) {
let calDay = function (_d, _cal) {
return new Date(_d.getTime() + (cal * 24 * 60 * 60 * 1000));
}
let tarDate = new Date(text);
let result = 0;
if (type == "year") {
result = calDay(tarDate, cal).getFullYear();
} else if (type == "month") {
result = calDay(tarDate, cal).getMonth();
} else if (type == "date") {
result = calDay(tarDate, cal).getDate();
} else if (type == "day") {
result = calDay(tarDate, cal).getDay();
} else {
result = calDay(tarDate, cal);
}
return result;
}
//取得 左下方 各系統小類
function getSubList() { function getSubList() {
let url = baseApiUrl + "/api/Device/GetMainSub"; let url = baseApiUrl + "/api/Device/GetMainSub";
let sendData = { let sendData = {
@ -698,8 +297,12 @@
} else { } else {
let strHtml = ``; let strHtml = ``;
let contest = ["E4", "EL", "L1", "M10", "M12"]
$.each(res.data.history_Main_Systems, (index, mainSysObj) => { $.each(res.data.history_Main_Systems, (index, mainSysObj) => {
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
if (contest.indexOf(subSysObj.sub_system_tag) != -1) {
sysSubList.push({ sysMainTag: mainSysObj.main_system_tag, sysSubTag: subSysObj.sub_system_tag });
}
strHtml += `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group" data-id="/${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}"> strHtml += `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group" data-id="/${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}">
<button type="button" class="btn btn-secondary col-4"><i class="fal fa-lightbulb-on fa-2x py-2"></i></button> <button type="button" class="btn btn-secondary col-4"><i class="fal fa-lightbulb-on fa-2x py-2"></i></button>
<button type="button" class="btn btn-secondary">${subSysObj.full_name}</button> <button type="button" class="btn btn-secondary">${subSysObj.full_name}</button>
@ -713,6 +316,7 @@
}, null, "POST").send(); }, null, "POST").send();
} }
//取得第一筆電錶
function getFirstEletric() { function getFirstEletric() {
let url = baseApiUrl + "/api/Device/GetDeviceList"; let url = baseApiUrl + "/api/Device/GetDeviceList";
let sendData = { let sendData = {
@ -736,33 +340,245 @@
}, null, "POST").send(); }, null, "POST").send();
} }
//從 baja 取得電表用電量
function getElectricBaja() { function getElectricBaja() {
let devNum = tarElePath.split("_").slice(0, 8).join("_"); let devNum = tarElePath.split("_").slice(0, 8).join("_");
let devPath = tarElePath.split("_").slice(0, 8).join("/"); let devPath = tarElePath.split("_").slice(0, 8).join("/");
let today = displayDate(new Date, "date").replaceAll("/", "-") + "T00:00:00"; let today = displayDate(new Date(), "date").replaceAll("/", "-") + "T00:00:00";
let yesterday = displayDate(new Date(new Date(today).getTime() - (24 * 60 * 60 * 1000)), "date").replaceAll("/", "-") + "T00:00:00"; let prevTwoWeek = displayDate(getTimeByType(null, -14), "date").replaceAll("/", "-") + "T00:00:00";
let tomorrow = displayDate(new Date(new Date(today).getTime() + (24 * 60 * 60 * 1000)), "date").replaceAll("/", "-") + "T00:00:00"; let yesterday = displayDate(getTimeByType(null,-1), "date").replaceAll("/", "-") + "T00:00:00";
let tomorrow = displayDate(getTimeByType(null, 1), "date").replaceAll("/", "-") + "T00:00:00";
//今日用電量 // 今日用電量
getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", today, tomorrow, (data) => { getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", today, tomorrow, (data) => {
data = JSON.parse(data); $("#todayUseElec").text(data?.data[0]?.sum || 0);
$("#todayUseElec").text(data?.data[0]?.sum || "");
}) })
//昨日用電量
// 今日用電量 (每小時)
getElectricMeterHourDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", yesterday, tomorrow, (data) => {
let todayData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year") && x.timestamp.$date.$month == getTimeByType("month") && x.timestamp.$date.$day == getTimeByType("date"));
let yesData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year", -1) && x.timestamp.$date.$month == getTimeByType("month", -1) && x.timestamp.$date.$day == getTimeByType("date", -1));
chartEveDaysElec(todayData, yesData);
})
// 昨日用電量
getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", yesterday, today, (data) => { getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", yesterday, today, (data) => {
data = JSON.parse(data); $("#yesUseElec").text(data?.data[0]?.sum || 0);
$("#yesUseElec").text(data?.data[0]?.sum || "");
}) })
// 本週與上週用電量 (每天)
getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", prevTwoWeek, tomorrow, (data) => {
let curDay = (new Date()).getDay() == 0 ? 7 : (new Date()).getDay();
let curWeekData = data.data.filter(x => strToDate(displayDate(new Date(),"date"), null, 0 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr));
let prevWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - 7 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr) && strToDate(new Date(), null, 0 - 7) >= strToDate(x.timestamp.$cEncStr));
chartEveWeeksElec(curWeekData, prevWeekData)
console.log(data)
})
// 電表即時功率
getElectricMeterNoweDataByBaja(devPath, (data) => { getElectricMeterNoweDataByBaja(devPath, (data) => {
console.log(data) console.log(data)
data = data.data; data = data.data;
$("#insPower").text(data.filter(x => x.name == "P")[0]?.value); $("#insPower").text(data.filter(x => x.name == "P")[0]?.value);
}) })
} }
// 圖表 - 今天與昨天用電量
function chartEveDaysElec(todayData, yesData) {
let eveDayElecChartCanvas = $('#eveDayElecChart').get(0).getContext('2d');
let color = { main1: "#1dc9b7", main2:"#17a2b8"}
let curHour = (new Date()).getHours();
todayData.data = todayData.filter(x => x.timestamp.$time.$hour < curHour);
yesData.data = yesData.filter(x => x.timestamp.$time.$hour < curHour);
let eveDayElecChartData = {
labels: todayData?.data.map(x => x.timestamp.$time.$hour),
datasets: [
{
id:"today",
type: "bar",
label: '今日用電量',
fill: false,
backgroundColor: color.main1,
borderColor: color.main1,
pointColor: color.main1,
pointBackgroundColor: color.main1,
data: todayData?.data.map(x => x.sum),
order: 1,
},
{
id: "yesterday",
type: "bar",
label: '昨日用電量',
fill: false,
backgroundColor: color.main2,
borderColor: color.main2,
pointColor: color.main2,
pointBackgroundColor: color.main2,
data: yesData?.data.map(x => x.sum),
order: 2,
}
]
}
let eveDayElecChartOptions = {
maintainAspectRatio: false,
responsive: true,
legend: {
display: true,
},
scales: {
xAxes: [{
offset: true,
gridLines: { color: "#505050" },
ticks: {
callback: function (value, index, ticks) {
return value
}
},
}],
yAxes: [{
ticks: {
min:0,
beginAtZero: true
},
}]
},
tooltips: {
callbacks: {
label: function (tooltipItem) {
let isTodayOrYes = tooltipItem.datasetIndex == 1 ? "昨日" : "今日";
return isTodayOrYes + "用電量 : " + tooltipItem.value + " kWH";
},
title: function (tooltipItem) {
let result = tooltipItem[0].xLabel.toString().padStart(2, "0") + ":00";
return result;
}
}
},
}
// This will get the first returned node in the jQuery collection.
eveDayElecChart = new Chart(eveDayElecChartCanvas, {
data: eveDayElecChartData,
options: eveDayElecChartOptions
})
}
// 圖表 - 這週與上週用電量
function chartEveWeeksElec(curWeekData, prevWeekData) {
let eveWeekElecChartCanvas = $('#eveWeekElecChart').get(0).getContext('2d');
let color = { main1: "#1dc9b7", main2: "#17a2b8" }
let eveWeekElecChartData = {
labels: curWeekData.map(x => dayToChiDay(strToDate(x.timestamp.$cEncStr, "day"))),
datasets: [
{
id: "today",
type: "bar",
label: '本週用電量',
fill: false,
backgroundColor: color.main1,
borderColor: color.main1,
pointColor: color.main1,
pointBackgroundColor: color.main1,
data: curWeekData.map(x => x.sum),
order: 1,
},
{
id: "yesterday",
type: "bar",
label: '上週用電量',
fill: false,
backgroundColor: color.main2,
borderColor: color.main2,
pointColor: color.main2,
pointBackgroundColor: color.main2,
data: prevWeekData.map(x => x.sum),
order: 2,
}
]
}
let eveWeekElecChartOptions = {
maintainAspectRatio: false,
responsive: true,
legend: {
display: true,
},
scales: {
xAxes: [{
offset: true,
gridLines: { color: "#505050" },
ticks: {
callback: function (value, index, ticks) {
return value
}
},
}],
yAxes: [{
ticks: {
min: 0,
beginAtZero: true
},
}]
},
tooltips: {
callbacks: {
label: function (tooltipItem) {
let isTodayOrYes = tooltipItem.datasetIndex == 1 ? "上週" : "本週";
return isTodayOrYes + "用電量 : " + tooltipItem.value + " kWH";
},
title: function (tooltipItem) {
let result = tooltipItem[0].xLabel.toString();
return result;
}
}
},
}
// This will get the first returned node in the jQuery collection.
eveWeekElecChart = new Chart(eveWeekElecChartCanvas, {
data: eveWeekElecChartData,
options: eveWeekElecChartOptions
})
}
//從 baja 訂閱 左下角各系統小類異常狀態
function getAlarmSub() { function getAlarmSub() {
var tipEle = '';
if (sysSubList.length != 0) {
tipEle = YT.Alert.Tip("資料讀取中...","show");
}
$(`.data-group i.fa-lightbulb-on`).removeClass("blink");
//debugger
$.each(sysSubList, (idx, sysSubObj) => {
let myBaja = new subscriptionAlarms();
let ordPath = {
"building_tag": pageAct.buiTag,
"system_tag": sysSubObj.sysMainTag,
"name_tag": sysSubObj.sysSubTag,
};
console.log("ordPath",ordPath)
myBaja.setSubscribeAlarmsByBql(ordPath);
myBaja.setSubscribeAlarmsCallBack((data) => {
if (data.sourceState == "Offnormal") {
let devNum = data.system.replaceAll("_", "/");
$(`.dev-group[data-id*='${devNum}'] i.fa-lightbulb-on`).addClass("blink");
}
})
myBaja.setSubscribeAlarmEndCallBack((data) => {
if (idx == sysSubList.length - 1) {
$(tipEle.ele).YTAlert().hide();
}
})
})
//$(".dev-group").each((idx, ele) => { //$(".dev-group").each((idx, ele) => {
@ -779,6 +595,7 @@
} }
function show3DModel() { function show3DModel() {
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDMjAyMjEyMDEubndk'); launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDMjAyMjEyMDEubndk');
} }

View File

@ -861,7 +861,7 @@
var subSeviceData = []; //每個設備訂閱點位值 var subSeviceData = []; //每個設備訂閱點位值
var floList = []; //每個樓層 var floList = []; //每個樓層
var elevObj = null; //左側 2D 電梯物件 var elevObj = null; //左側 2D 電梯物件
var viewer3DNodeIds = [760, 754, 748]; var viewer3DNodeIds = [12115, 12109, 12103];
var elev3DBind = {}; var elev3DBind = {};
var elev3DOption = {}; var elev3DOption = {};
var elev3DObj = []; var elev3DObj = [];
@ -2396,7 +2396,7 @@
function load3DModel() { function load3DModel() {
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDMjAyMjEyMDEubndk', (viewer) => { launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQ18yMDIyMTIwNS5ud2Q', (viewer) => {
$.each(viewer3DNodeIds, function (idx, node) { $.each(viewer3DNodeIds, function (idx, node) {
let options = { let options = {
element: $("#forgeViewer"), element: $("#forgeViewer"),

View File

@ -33,6 +33,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<link rel="mask-icon" href="img/favicon/safari-pinned-tab.svg" color="#5bbad5"> <link rel="mask-icon" href="img/favicon/safari-pinned-tab.svg" color="#5bbad5">
<!-- Font Awesome --> <!-- Font Awesome -->
<link href="lib/fontawesome-free/css/all.min.css" rel="stylesheet" /> <link href="lib/fontawesome-free/css/all.min.css" rel="stylesheet" />
<link href="lib/chart.js/Chart.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" media="screen, print" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap.min.css"> <link rel="stylesheet" media="screen, print" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" media="screen, print" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css"> <link rel="stylesheet" media="screen, print" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css">
@ -131,8 +132,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<!-- BEGIN Left Aside --> <!-- BEGIN Left Aside -->
<aside class="page-sidebar hidden-lg-up"> <aside class="page-sidebar hidden-lg-up">
<div class="page-logo"> <div class="page-logo">
<a href="#" class="page-logo-link press-scale-down d-flex align-items-center position-relative" <a href="javascript:;" name="topFunBtn" data-page="dashboard" class="page-logo-link press-scale-down d-flex align-items-center position-relative">
data-toggle="modal" data-target="#modal-shortcut">
<img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo"> <img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<span class="page-logo-text mr-1">System</span> <span class="page-logo-text mr-1">System</span>
<span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span> <span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
@ -1412,13 +1412,12 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<header class="page-header" role="banner"> <header class="page-header" role="banner">
<!-- we need this logo when user switches to nav-function-top --> <!-- we need this logo when user switches to nav-function-top -->
<div class="page-logo"> <div class="page-logo">
<a href="#" class="page-logo-link press-scale-down d-flex align-items-center position-relative" <a href="javascript:;" name="topFunBtn" data-page="dashboard" class="page-logo-link press-scale-down d-flex align-items-center position-relative">
data-toggle="modal" data-target="#modal-shortcut">
<img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo"> <img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<!--<span class="page-logo-text mr-1">SmartAdmin WebApp</span> <!--<span class="page-logo-text mr-1">SmartAdmin WebApp</span>
<span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span> <span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
<i class="fal fa-angle-down d-inline-block ml-1 fs-lg color-primary-300"></i>--> <i class="fal fa-angle-down d-inline-block ml-1 fs-lg color-primary-300"></i>-->
</a> </a>
</div> </div>
@ -1569,7 +1568,52 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
</footer>--> </footer>-->
<!-- END Page Footer --> <!-- END Page Footer -->
<!-- BEGIN Shortcuts --> <!-- BEGIN Shortcuts -->
<!--<div class="modal fade modal-backdrop-transparent" id="modal-shortcut" tabindex="-1" role="dialog"
aria-labelledby="modal-shortcut" aria-hidden="true">
<div class="modal-dialog modal-dialog-top modal-transparent" role="document">
<div class="modal-content">
<div class="modal-body">
<ul class="app-list w-auto h-auto p-0 text-left">
<li>
<a href="intel_introduction.html" class="app-list-item text-white border-0 m-0">
<div class="icon-stack">
<i class="base base-7 icon-stack-3x opacity-100 color-primary-500 "></i>
<i class="base base-7 icon-stack-2x opacity-100 color-primary-300 "></i>
<i class="fal fa-home icon-stack-1x opacity-100 color-white"></i>
</div>
<span class="app-list-name">
Home
</span>
</a>
</li>
<li>
<a href="page_inbox_general.html" class="app-list-item text-white border-0 m-0">
<div class="icon-stack">
<i class="base base-7 icon-stack-3x opacity-100 color-success-500 "></i>
<i class="base base-7 icon-stack-2x opacity-100 color-success-300 "></i>
<i class="ni ni-envelope icon-stack-1x text-white"></i>
</div>
<span class="app-list-name">
Inbox
</span>
</a>
</li>
<li>
<a href="intel_introduction.html" class="app-list-item text-white border-0 m-0">
<div class="icon-stack">
<i class="base base-7 icon-stack-2x opacity-100 color-primary-300 "></i>
<i class="fal fa-plus icon-stack-1x opacity-100 color-white"></i>
</div>
<span class="app-list-name">
Add More
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>-->
<!-- END Shortcuts --> <!-- END Shortcuts -->
<!-- BEGIN Color profile --> <!-- BEGIN Color profile -->
<!-- this area is hidden and will not be seen on screens or screen readers --> <!-- this area is hidden and will not be seen on screens or screen readers -->
@ -2084,9 +2128,10 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
"n4js/historybaja", "n4js/historybaja",
"lib/statistics/flot/flot.bundle", "lib/statistics/flot/flot.bundle",
"lib/statistics/peity/peity.bundle", "lib/statistics/peity/peity.bundle",
"lib/jquery-validation/dist/jquery.validate", "lib/jquery-validation/dist/jquery.validate",
"lib/jquery-validation/dist/additional-methods.min", "lib/jquery-validation/dist/additional-methods.min",
"lib/jquery-validation/dist/localization/messages_zh_TW", "lib/jquery-validation/dist/localization/messages_zh_TW",
"lib/chart.js/Chart.min",
], loadedMasterPack); ], loadedMasterPack);
} }
/** /**

View File

@ -2,9 +2,11 @@
let baja_subscribe_end_device_callback_func; //設定BQL訂閱結束之後要回傳的Function let baja_subscribe_end_device_callback_func; //設定BQL訂閱結束之後要回傳的Function
let baja_my_user_account_func; //取得帳號資料要回傳的Function let baja_my_user_account_func; //取得帳號資料要回傳的Function
var ordPath; //當前點選選單的tag用來抓出設備路徑例如:旅館棟->H消防偵煙器->F3 var ordPath; //當前點選選單的tag用來抓出設備路徑例如:旅館棟->H消防偵煙器->F3
let baja_subscribe_alarm_callback_func; //設定 alarm BQL訂閱之後要回傳的Function let baja_subscribe_alarm_callback_func; //設定 alarm BQL訂閱之後要回傳的Function
let baja_subscribe_end_alarm_callback_func; //設定 alarm BQL訂閱結束之後要回傳的Function let baja_subscribe_end_alarm_callback_func; //設定 alarm BQL訂閱結束之後要回傳的Function
var ordPathForAlarm; //當前點選選單的tag用來抓出alarm路徑 var ordPathForAlarm; //當前點選選單的tag用來抓出alarm路徑
window.tolSubList = []; window.tolSubList = [];
var user_name = ""; var user_name = "";
@ -32,8 +34,7 @@ function subscriptionDevices() {
function subscriptionAlarms() { function subscriptionAlarms() {
// 用BQL的方式去訂閱 // 用BQL的方式去訂閱
this.setSubscribeAlarmsByBql = function (tempOrdPath) { this.setSubscribeAlarmsByBql = function (tempOrdPath) {
ordPathForAlarm = tempOrdPath; BajaSubscribeAlarmsByBql(tempOrdPath);
BajaSubscribeAlarmsByBql();
}; };
// BQL去訂閱回傳的Function // BQL去訂閱回傳的Function
this.setSubscribeAlarmsCallBack = function (callBackFunc) { this.setSubscribeAlarmsCallBack = function (callBackFunc) {
@ -66,6 +67,8 @@ function MyBaja() {
* 使用者透過BQL指定路徑去訂閱設備點位 * 使用者透過BQL指定路徑去訂閱設備點位
*/ */
function BajaSubscribeDevicesByBql() { function BajaSubscribeDevicesByBql() {
require(['baja!'], function (baja) { require(['baja!'], function (baja) {
console.log("進入Function 準備執行BQL訂閱"); console.log("進入Function 準備執行BQL訂閱");
var init_start = new Date(Date.now()); var init_start = new Date(Date.now());
@ -168,7 +171,7 @@ function BajaSubscribeDevicesByBql() {
var modify_target_device = { var modify_target_device = {
"device_number": target_device_number ? target_device_number : null, "device_number": target_device_number ? target_device_number : null,
"device_number_full": this.getDisplay("slotPath").split("slot:")[1].split('/').slice(1,-1).join("_"), "device_number_full": this.getDisplay("slotPath").split("slot:")[1].split('/').slice(1, -1).join("_"),
"point_name": point_name ? point_name : null, "point_name": point_name ? point_name : null,
"value": key "value": key
} }
@ -249,7 +252,7 @@ function BajaSubscribeDevicesByBql() {
/** /**
* 使用者透過BQL指定路徑去訂閱Alarm * 使用者透過BQL指定路徑去訂閱Alarm
*/ */
function BajaSubscribeAlarmsByBql() { function BajaSubscribeAlarmsByBql(ordPathForAlarm) {
require(['baja!'], function (baja) { require(['baja!'], function (baja) {
console.log("進入Function 準備執行BQL訂閱"); console.log("進入Function 準備執行BQL訂閱");
var init_start = new Date(Date.now()); var init_start = new Date(Date.now());
@ -258,6 +261,7 @@ function BajaSubscribeAlarmsByBql() {
sub.attach('changed', function (prop) { sub.attach('changed', function (prop) {
if (prop.getName() === 'out') { if (prop.getName() === 'out') {
var sourceState = (this.$map.$map.in10.$val.$map.$map.value.$display) == 'true' ? "Offnormal" : "Normal"; var sourceState = (this.$map.$map.in10.$val.$map.$map.value.$display) == 'true' ? "Offnormal" : "Normal";
var modify_target_device = { var modify_target_device = {
"system": "TPE_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag, "system": "TPE_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag,
"sourceState": sourceState ? sourceState : null "sourceState": sourceState ? sourceState : null
@ -270,12 +274,13 @@ function BajaSubscribeAlarmsByBql() {
}); });
//使用bql語法 //使用bql語法
console.log(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, alarmData, alarmData.sourceName, normalTime where alarmData.sourceName like '%TPE_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`); console.log(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, normalTime where alarmData.sourceName like '%TPE_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`);
baja.Ord.make(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, alarmData, alarmData.sourceName, normalTime where alarmData.sourceName like '%TPE_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`) baja.Ord.make(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, alarmData, alarmData.sourceName, normalTime where alarmData.sourceName like '%TPE_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`)
.get( .get(
function (table) { function (table) {
var tableStart, tableFinish; var tableStart, tableFinish;
var subStart, subFinish; var subStart, subFinish;
var totalTargetDevice = [];
var component_index = 0; var component_index = 0;
var total_component_index = 0; var total_component_index = 0;
var readBqlFinish = new Date(Date.now()); var readBqlFinish = new Date(Date.now());
@ -283,6 +288,7 @@ function BajaSubscribeAlarmsByBql() {
table.cursor({ table.cursor({
before: function () { before: function () {
totalTargetDevice = [];
tableStart = new Date(Date.now()); tableStart = new Date(Date.now());
render_start = new Date(Date.now()); render_start = new Date(Date.now());
}, },
@ -293,6 +299,7 @@ function BajaSubscribeAlarmsByBql() {
total_component_index = index; total_component_index = index;
var sourceState = this.getDisplay("sourceState"); var sourceState = this.getDisplay("sourceState");
//var sourceName = (item.$map.$map.alarmData$2esourceName.$display).replace('_', '/');
var sourceNameArray = (item.$map.$map.alarmData$2esourceName.$display).split('_'); var sourceNameArray = (item.$map.$map.alarmData$2esourceName.$display).split('_');
var slotPath = sourceNameArray[0] + "/" + sourceNameArray[1] + "/" + sourceNameArray[2] + "/" + sourceNameArray[3] + "/" + sourceNameArray[4] + "/" + sourceNameArray[5] + "/" + sourceNameArray[6] + "/" + sourceNameArray[7] + "/" + sourceNameArray[8]; var slotPath = sourceNameArray[0] + "/" + sourceNameArray[1] + "/" + sourceNameArray[2] + "/" + sourceNameArray[3] + "/" + sourceNameArray[4] + "/" + sourceNameArray[5] + "/" + sourceNameArray[6] + "/" + sourceNameArray[7] + "/" + sourceNameArray[8];
var normalTime = this.getDisplay("normalTime"); var normalTime = this.getDisplay("normalTime");
@ -301,7 +308,7 @@ function BajaSubscribeAlarmsByBql() {
"system": "TPE_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag, "system": "TPE_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag,
"sourceState": sourceState ? sourceState : null "sourceState": sourceState ? sourceState : null
} }
totalTargetDevice.push(modify_target_device);
//取得component當下就更新設備點位 //取得component當下就更新設備點位
if (baja_subscribe_alarm_callback_func != undefined && baja_subscribe_alarm_callback_func != null) { if (baja_subscribe_alarm_callback_func != undefined && baja_subscribe_alarm_callback_func != null) {
baja_subscribe_alarm_callback_func(modify_target_device); baja_subscribe_alarm_callback_func(modify_target_device);
@ -322,6 +329,9 @@ function BajaSubscribeAlarmsByBql() {
}, },
after: function () { after: function () {
tableFinish = new Date(Date.now()); tableFinish = new Date(Date.now());
if (baja_subscribe_end_alarm_callback_func != undefined && baja_subscribe_end_alarm_callback_func != null) {
baja_subscribe_end_alarm_callback_func(totalTargetDevice);
}
console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec");
}, },
limit: -1, limit: -1,
@ -330,3 +340,107 @@ function BajaSubscribeAlarmsByBql() {
}); });
}); });
} }
// function getAlarmCountByBaja(callback) {
// var _result = "";
// var _index = 0;
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where sourceState = 'offnormal' order by timestamp desc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
// }
// /**
// * [首頁] 查詢復歸數量
// * @param {any} callback
// */
// function getRecoverCountByBaja(callback) {
// var _result = "";
// var _index = 0;
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where normalTime != null order by timestamp desc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
// }
// function getCheckedAckedCountByBaja(callback) {
// var _result = "";
// var _index = 0;
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where ackState ='acked' order by timestamp asc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
// }
// function getUnCheckedAckedCountByBaja(callback) {
// var _result = "";
// var _index = 0;
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where ackState ='unacked' order by timestamp asc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// },
// limit: -1,
// offset: 0
// });
// });
// });
// }

View File

@ -156,8 +156,7 @@ function getElectricMeterOneDayKwhByBaja(devicePath, date_millisecond, callback)
* @param {any} callback * @param {any} callback
*/ */
function getElectricMeterWeekDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, callback) { function getElectricMeterWeekDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, callback) {
var _result = ""; var _result = { count: 0, data: [] };
var _ss = "";
var _index = 0; var _index = 0;
require(['baja!'], function (baja) {//TPE/B1/EE/E4/R2F/NA/WHT/N1 require(['baja!'], function (baja) {//TPE/B1/EE/E4/R2F/NA/WHT/N1
@ -166,16 +165,14 @@ function getElectricMeterWeekDataByBaja(devicePath, startDate_millisecond, endDa
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
if (_index == 0) let main = {};
_ss += '{"timestamp":' + record.get('timestamp') + ', "value":"' + record.get('kwh1') + '"}'; main.timestamp = record.get('timestamp');
else main.value = record.get('kwh1');
_ss += ',{"timestamp":' + record.get('timestamp') + ', "value":"' + record.get('kwh1') + '"}'; _result.data.push(main);
_index++; _index++;
}, },
after: function () { after: function () {
_result += '{' + '"count": ' + _index + ', "data":['; _result.count = _index;
_result += _ss;
_result += ']}';
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(_result); callback(_result);
} }
@ -236,8 +233,7 @@ function getElectricMeterKwhAvgDataByBaja(devicePath, company, startDate_millise
* @param {any} callback * @param {any} callback
*/ */
function getElectricMeterHourDataByBaja(devicePath, company, startDateTime, endDateTime, callback) { function getElectricMeterHourDataByBaja(devicePath, company, startDateTime, endDateTime, callback) {
var _result = ""; var _result = { count: 0, data: [] };
var _ss = "";
var _index = 0; var _index = 0;
require(['baja!'], function (baja) {//TPE_B1_EE_E4_R2F_NA_WHT_N1_KWH require(['baja!'], function (baja) {//TPE_B1_EE_E4_R2F_NA_WHT_N1_KWH
@ -246,16 +242,18 @@ function getElectricMeterHourDataByBaja(devicePath, company, startDateTime, endD
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
if (_index == 0) let main = {};
_ss += '{"timestamp":' + record.get('timestamp') + ', "endTimestamp":"' + record.get('endTimestamp') + ', "min":"' + record.get('min') + ', "max":"' + record.get('max') + ', "avg":"' + record.get('avg') + ', "sum":"' + record.get('sum') + '"}'; main.timestamp = record.get('timestamp');
else main.endTimestamp = record.get('endTimestamp');
_ss += ',{"timestamp":' + record.get('timestamp') + ', "endTimestamp":"' + record.get('endTimestamp') + ', "min":"' + record.get('min') + ', "max":"' + record.get('max') + ', "avg":"' + record.get('avg') + ', "sum":"' + record.get('sum') + '"}'; main.min = record.get('min');
main.max = record.get('max');
main.avg = record.get('avg');
main.sum = record.get('sum');
_result.data.push(main);
_index++; _index++;
}, },
after: function () { after: function () {
_result += '{' + '"count": ' + _index + ', "data":['; _result.count = _index;
_result += _ss;
_result += ']}';
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(_result); callback(_result);
} }
@ -276,8 +274,7 @@ function getElectricMeterHourDataByBaja(devicePath, company, startDateTime, endD
* @param {any} callback * @param {any} callback
*/ */
function getElectricMeterDayDataByBaja(devicePath, company, startDateTime, endDateTime, callback) { function getElectricMeterDayDataByBaja(devicePath, company, startDateTime, endDateTime, callback) {
var _result = ""; var _result = { count: 0, data: [] };
var _ss = "";
var _index = 0; var _index = 0;
require(['baja!'], function (baja) {//TPE_B1_EE_E4_R2F_NA_WHT_N1_KWH require(['baja!'], function (baja) {//TPE_B1_EE_E4_R2F_NA_WHT_N1_KWH
@ -286,16 +283,19 @@ function getElectricMeterDayDataByBaja(devicePath, company, startDateTime, endDa
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
if (_index == 0) let main = {};
_ss += '{"timestamp":"' + record.get('timestamp') + '", "endTimestamp":"' + record.get('endTimestamp') + '", "min":"' + record.get('min') + '", "max":"' + record.get('max') + '", "avg":"' + record.get('avg') + '", "sum":"' + record.get('sum') + '"}'; main.timestamp = record.get('timestamp');
else main.endTimestamp = record.get('endTimestamp');
_ss += ',{"timestamp":"' + record.get('timestamp') + '", "endTimestamp":"' + record.get('endTimestamp') + '", "min":"' + record.get('min') + '", "max":"' + record.get('max') + '", "avg":"' + record.get('avg') + '", "sum":"' + record.get('sum') + '"}'; main.min = record.get('min');
main.max = record.get('max');
main.avg = record.get('avg');
main.sum = record.get('sum');
_result.data.push(main);
_index++; _index++;
}, },
after: function () { after: function () {
_result += '{' + '"count": ' + _index + ', "data":['; _result.count = _index;
_result += _ss;
_result += ']}';
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(_result); callback(_result);
} }

View File

@ -0,0 +1 @@


File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
/*
* DOM element rendering detection
* https://davidwalsh.name/detect-node-insertion
*/
@keyframes chartjs-render-animation {
from { opacity: 0.99; }
to { opacity: 1; }
}
.chartjs-render-monitor {
animation: chartjs-render-animation 0.001s;
}
/*
* DOM element resizing detection
* https://github.com/marcj/css-element-queries
*/
.chartjs-size-monitor,
.chartjs-size-monitor-expand,
.chartjs-size-monitor-shrink {
position: absolute;
direction: ltr;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
pointer-events: none;
visibility: hidden;
z-index: -1;
}
.chartjs-size-monitor-expand > div {
position: absolute;
width: 1000000px;
height: 1000000px;
left: 0;
top: 0;
}
.chartjs-size-monitor-shrink > div {
position: absolute;
width: 200%;
height: 200%;
left: 0;
top: 0;
}

16151
Frontend/lib/chart.js/Chart.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
Frontend/lib/chart.js/Chart.min.css vendored Normal file
View File

@ -0,0 +1 @@
@keyframes chartjs-render-animation{from{opacity:.99}to{opacity:1}}.chartjs-render-monitor{animation:chartjs-render-animation 1ms}.chartjs-size-monitor,.chartjs-size-monitor-expand,.chartjs-size-monitor-shrink{position:absolute;direction:ltr;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1}.chartjs-size-monitor-expand>div{position:absolute;width:1000000px;height:1000000px;left:0;top:0}.chartjs-size-monitor-shrink>div{position:absolute;width:200%;height:200%;left:0;top:0}

7
Frontend/lib/chart.js/Chart.min.js vendored Normal file

File diff suppressed because one or more lines are too long