[Frontend][系統監控] 電梯頁面 右側點位控制程序調整 | 右側緊急迴轉介面調整 | [儀錶板] 計時器程序建置 | [能源管理] 介面串接 | 介面調整 |系統小類 Card 建置 | 下方圖表 程序建置 | loading 程序建置 | 再生能源靜態程序建置
This commit is contained in:
parent
2c599b962c
commit
bc0d397108
@ -247,7 +247,12 @@
|
||||
var elev3DBind = {};
|
||||
var elev3DOption = {};
|
||||
var elev3DObj = [];
|
||||
var timeOutor = null; //刷新 baja 資料 定時器
|
||||
var timeOuters = [];
|
||||
var eveDayElecChart = null;
|
||||
var eveWeekElecChart = null;
|
||||
var errRecChart = null;
|
||||
var errChkChart = null;
|
||||
|
||||
var sysIconList = [
|
||||
{ mainSys: "EE", subSys: "E1", iconClass: "fal fa-grip-vertical" },
|
||||
{ mainSys: "EE", subSys: "E2", iconClass: "fal fa-grip-horizontal" },
|
||||
@ -268,39 +273,6 @@
|
||||
timeOutGetData();
|
||||
});
|
||||
|
||||
// 從數字週數轉為中文週數
|
||||
function dayToChiDay(num) {
|
||||
let chiDay = ["週日", "週一", "週二", "週三", "週四", "週五", "週六"];
|
||||
return chiDay[num];
|
||||
}
|
||||
|
||||
// 取得現在或前後時間,輸出單位依據 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() {
|
||||
let url = baseApiUrl + "/api/Device/GetMainSub";
|
||||
@ -444,7 +416,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 圖表 - 今天與昨天用電量 (折線圖)
|
||||
// 圖表 - 今天與昨天用電量 (長條圖)
|
||||
function chartEveDaysElec(todayData, yesData) {
|
||||
|
||||
let eveDayElecChartCanvas = $('#eveDayElecChart').get(0).getContext('2d');
|
||||
@ -519,14 +491,25 @@
|
||||
},
|
||||
}
|
||||
|
||||
// This will get the first returned node in the jQuery collection.
|
||||
eveDayElecChart = new Chart(eveDayElecChartCanvas, {
|
||||
data: eveDayElecChartData,
|
||||
options: eveDayElecChartOptions
|
||||
})
|
||||
if (eveDayElecChart == null) {
|
||||
eveDayElecChart = new Chart(eveDayElecChartCanvas, {
|
||||
data: eveDayElecChartData,
|
||||
options: eveDayElecChartOptions
|
||||
})
|
||||
} else {
|
||||
eveDayElecChart.data.datasets.forEach((dataset) => {
|
||||
if (dataset.order == 1) {
|
||||
dataset.data = todayData?.data.map(x => x.sum);
|
||||
} else {
|
||||
dataset.data = yesData?.data.map(x => x.sum);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 圖表 - 這週與上週用電量 (折線圖)
|
||||
// 圖表 - 這週與上週用電量 (長條圖)
|
||||
function chartEveWeeksElec(curWeekData, prevWeekData) {
|
||||
|
||||
let eveWeekElecChartCanvas = $('#eveWeekElecChart').get(0).getContext('2d');
|
||||
@ -598,11 +581,20 @@
|
||||
},
|
||||
}
|
||||
|
||||
// This will get the first returned node in the jQuery collection.
|
||||
eveWeekElecChart = new Chart(eveWeekElecChartCanvas, {
|
||||
data: eveWeekElecChartData,
|
||||
options: eveWeekElecChartOptions
|
||||
})
|
||||
if (eveWeekElecChart == null) {
|
||||
eveWeekElecChart = new Chart(eveWeekElecChartCanvas, {
|
||||
data: eveWeekElecChartData,
|
||||
options: eveWeekElecChartOptions
|
||||
})
|
||||
} else {
|
||||
eveWeekElecChart.data.datasets.forEach((dataset) => {
|
||||
if (dataset.order == 1) {
|
||||
dataset.data = curWeekData.map(x => x.sum);
|
||||
} else {
|
||||
dataset.data = prevWeekData.map(x => x.sum);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 圖表 - 異常與賦歸圖表 (圓餅圖)
|
||||
@ -638,11 +630,17 @@
|
||||
}
|
||||
|
||||
// This will get the first returned node in the jQuery collection.
|
||||
let errRecChart = new Chart(errRecChartCanvas, {
|
||||
type: "pie",
|
||||
data: errRecChartData,
|
||||
options: errRecChartOptions
|
||||
})
|
||||
if (errRecChart == null) {
|
||||
errRecChart = new Chart(errRecChartCanvas, {
|
||||
type: "pie",
|
||||
data: errRecChartData,
|
||||
options: errRecChartOptions
|
||||
})
|
||||
} else {
|
||||
errRecChart.data.datasets.forEach((dataset) => {
|
||||
dataset.data = datas;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 圖表 - 異常確認與未確認圖表 (圓餅圖)
|
||||
@ -677,12 +675,18 @@
|
||||
|
||||
}
|
||||
|
||||
// This will get the first returned node in the jQuery collection.
|
||||
let errChkChart = new Chart(errChkChartCanvas, {
|
||||
type: "pie",
|
||||
data: errChkChartData,
|
||||
options: errChkChartOptions
|
||||
})
|
||||
if (errChkChart == null) {
|
||||
errChkChart = new Chart(errChkChartCanvas, {
|
||||
type: "pie",
|
||||
data: errChkChartData,
|
||||
options: errChkChartOptions
|
||||
})
|
||||
} else {
|
||||
errChkChart.data.datasets.forEach((dataset) => {
|
||||
dataset.data = datas;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 從 baja 訂閱 左下角各系統小類異常狀態
|
||||
@ -694,7 +698,7 @@
|
||||
/*$(`.dev-group i.fa-lightbulb-on`)*/
|
||||
|
||||
getSystemAlarmByBaja((data) => {
|
||||
|
||||
console.log(data)
|
||||
$.each(data.data, (idx, alaObj) => {
|
||||
if (alaObj.alarmClass.indexOf("_") != -1) {
|
||||
let mainSubSys = alaObj.alarmClass.split("_").slice(0, 2).join("/");
|
||||
@ -740,13 +744,17 @@
|
||||
}
|
||||
|
||||
function timeOutGetData() {
|
||||
timeOutor = setInterval(() => {
|
||||
let timeOut3s = setInterval(() => {
|
||||
getAlarmSub();
|
||||
},3000)
|
||||
}, 3000)
|
||||
let timeOut5m = setInterval(() => {
|
||||
getElectricBaja();
|
||||
}, 5 * 60 * 1000)
|
||||
timeOuters = timeOuters.concat([timeOut3s, timeOut5m]);
|
||||
}
|
||||
|
||||
function show3DModel() {
|
||||
launchViewer(pageAct.urn, (viewer, nodeIds) => {
|
||||
launchViewerNoTools(pageAct.urn, (viewer, nodeIds) => {
|
||||
nodeIds = Array.from(nodeIds);
|
||||
$.each(nodeIds, (idx, item) => {
|
||||
elev3DBind[item[0]] = item[1];
|
||||
@ -807,7 +815,11 @@
|
||||
}
|
||||
data.device_number = data.device_number_full;
|
||||
let matchDevice = allEleDevList.filter(x => x.device_number == data.device_number)[0];
|
||||
let master = matchDevice.device_number.split("_")[5];
|
||||
let master = matchDevice?.device_number.split("_")[5];
|
||||
|
||||
if (!matchDevice) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.point_name == "CP") {
|
||||
if (elev3DObj.length != 0) {
|
||||
|
@ -2,83 +2,43 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-xl-7">
|
||||
<div class="btn-group mb-3">
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">用電管理</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">天然氣管理</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">水資源管理</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">再生能源</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed active" data-id="0" data-tabname="energyTab">用電管理</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" data-id="1" data-tabname="energyTab">天然氣管理</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" data-id="2" data-tabname="energyTab">水資源管理</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" data-id="3" data-tabname="energyTab">再生能源</button>
|
||||
</div>
|
||||
<div class="row" >
|
||||
<div id="eneSubSysList" class="row col-12"></div>
|
||||
<div id="eneSubSysList" class="row col-12 m-0 p-0"></div>
|
||||
|
||||
<div class="col-sm-12 col-xl-12">
|
||||
<div id="panel-2" class="panel panel-locked" data-panel-sortable data-panel-collapsed data-panel-close>
|
||||
<div class="panel-hdr">
|
||||
<h2>
|
||||
空調系統 - 用電狀況
|
||||
<span id="actSubSysText"></span> - 用電狀況
|
||||
</h2>
|
||||
</div>
|
||||
<div class="panel-container show">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-6">
|
||||
<div class="col-sm-12 col-lg-6 d-flex flex-column">
|
||||
<h4 class="p-3">今日耗電量 kWh</h4>
|
||||
<div class="panel-content poisition-relative" style="min-height: 346.84px;">
|
||||
<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="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='icon-stack mr-2'>
|
||||
<i class="base base-7 icon-stack-3x opacity-100 color-success-600"></i>
|
||||
<i class="base base-7 icon-stack-2x opacity-100 color-success-500"></i>
|
||||
<i class="fal fa-arrow-up icon-stack-1x opacity-100 color-white"></i>
|
||||
</div>
|
||||
$44.34 / GE
|
||||
</div>
|
||||
<span class="m-0 fs-xs text-muted">Increased Profit as per redux margins and estimates</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="js-easy-pie-chart color-info-400 position-relative d-inline-flex align-items-center justify-content-center" data-percent="35" data-piesize="95" data-linewidth="10" data-scalelength="5">
|
||||
<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>
|
||||
</div>
|
||||
<div id="todayElecNoData" class="row justify-content-center align-items-center h-100" style="display:none;">
|
||||
<h4>無資料</h4>
|
||||
</div>
|
||||
<div style="width:100%; min-height:300px;">
|
||||
<canvas class="chart" id="todayElecChart"></canvas>
|
||||
</div>
|
||||
<div id="flot-area" style="width:100%; height:300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-6">
|
||||
<div class="col-sm-12 col-lg-6 d-flex flex-column">
|
||||
<h4 class="py-3">用電比較</h4>
|
||||
<div class="pb-5 pt-3">
|
||||
<div class="row">
|
||||
<div class="col-6 col-xl-3 d-sm-flex align-items-center">
|
||||
<div class="p-2 mr-3 bg-info-200 rounded">
|
||||
<span class="peity-bar" data-peity="{"fill": ["#fff"], "width": 27, "height": 27 }">3,4,5,8,2</span>
|
||||
</div>
|
||||
<div>
|
||||
<label class="fs-sm mb-0">Bounce Rate</label>
|
||||
<h4 class="font-weight-bold mb-0">37.56%</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-xl-3 d-sm-flex align-items-center">
|
||||
<div class="p-2 mr-3 bg-info-300 rounded">
|
||||
<span class="peity-bar" data-peity="{"fill": ["#fff"], "width": 27, "height": 27 }">5,3,1,7,9</span>
|
||||
</div>
|
||||
<div>
|
||||
<label class="fs-sm mb-0">Sessions</label>
|
||||
<h4 class="font-weight-bold mb-0">759</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-xl-3 d-sm-flex align-items-center">
|
||||
<div class="p-2 mr-3 bg-success-300 rounded">
|
||||
<span class="peity-bar" data-peity="{"fill": ["#fff"], "width": 27, "height": 27 }">3,4,3,5,5</span>
|
||||
</div>
|
||||
<div>
|
||||
<label class="fs-sm mb-0">New Sessions</label>
|
||||
<h4 class="font-weight-bold mb-0">12.17%</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="elecCompNoData" class="row justify-content-center align-items-center h-100" style="display:none;">
|
||||
<h4>無資料</h4>
|
||||
</div>
|
||||
<div style="width:100%; min-height:300px;">
|
||||
<canvas class="chart" id="elecCompChart"></canvas>
|
||||
|
||||
</div>
|
||||
<div id="flotVisit" style="width:100%; height:208px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -238,13 +198,18 @@
|
||||
<script>
|
||||
var subSysList = [];
|
||||
var subSysElecList = [];
|
||||
var todayElecChart = null;
|
||||
var elecCompChart = null;
|
||||
var elecCardConText = [{ text1: "即時功耗 kW", text2:"佔比 %"},{ text1: "即時功耗 kW", text2:"佔比 %"},{ text1: "即時功耗 kW", text2:"佔比 %"},{ text1: "即時發電功率 kW", text2:"供電佔比 %"}]
|
||||
|
||||
$(function () {
|
||||
getSubSysList();
|
||||
getElecBySubSysTag();
|
||||
})
|
||||
|
||||
// 左上方 系統小類卡片區塊
|
||||
function getSubSysList() {
|
||||
function getSubSysList(type = 0) {
|
||||
subSysList = [];
|
||||
let url = baseApiUrl + "/api/Device/GetMainSub";
|
||||
let sendData = {
|
||||
building_tag: pageAct.buiTag,
|
||||
@ -258,28 +223,32 @@
|
||||
$.each(res.data.history_Main_Systems, (index, mainSysObj) => {
|
||||
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
|
||||
subSysList.push(subSysObj);
|
||||
if (type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) {
|
||||
strHtml += `<div class="col-sm-12 col-xl-4 mb-2">
|
||||
<div class="card">
|
||||
<div class="card elecCard cur-poi" data-id="${mainSysObj.main_system_tag}_${subSysObj.sub_system_tag}" data-name="${subSysObj.full_name}">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title color-white">${subSysObj.full_name}用電</h4>
|
||||
<p class="card-text color-white pl-5 pr-3 d-flex justify-content-between">
|
||||
<span>即時功耗 kW</span>
|
||||
<span id="imdPow${subSysObj.sub_system_tag}"></span>
|
||||
<span>${elecCardConText[type]?.text1}</span>
|
||||
<span id="insPow${mainSysObj.main_system_tag}_${subSysObj.sub_system_tag}"></span>
|
||||
</p>
|
||||
<p class="card-text color-white pl-5 pr-3 d-flex justify-content-between">
|
||||
<span>佔比 %</span>
|
||||
<span id="imdPowPer${subSysObj.sub_system_tag}"></span>
|
||||
<span>${elecCardConText[type]?.text2}</span>
|
||||
<span id="insPowPer${mainSysObj.main_system_tag}_${subSysObj.sub_system_tag}"></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
})
|
||||
})
|
||||
$("#eneSubSysList").html(strHtml);
|
||||
}
|
||||
}, null, "POST").send();
|
||||
|
||||
}
|
||||
|
||||
// 取得 對應系統小類的總電錶
|
||||
function getElecBySubSysTag() {
|
||||
let url = baseApiUrl + "/api/Energe/GetElecBySubSysTag";
|
||||
|
||||
@ -288,13 +257,259 @@
|
||||
|
||||
} else {
|
||||
subSysElecList = res.data;
|
||||
getBajaData();
|
||||
}
|
||||
}, null, "POST").send();
|
||||
}
|
||||
|
||||
// 取得 baja 即時資料
|
||||
function getBajaData() {
|
||||
$.each(subSysElecList, (idx, subSysObj) => {
|
||||
startPageLoading();
|
||||
let yesterday = displayDate(getTimeByType(null, -1), "date").replaceAll("/", "-") + "T00:00:00";
|
||||
let tomorrow = displayDate(getTimeByType(null, 1), "date").replaceAll("/", "-") + "T00:00:00";
|
||||
let prevThirtyDay = displayDate(getTimeByType(null, -30), "date").replaceAll("/", "-") + "T00:00:00";
|
||||
let lastTimeout = null;
|
||||
let totalPow = 0;
|
||||
let loadedCnt = 0;
|
||||
|
||||
// 取系統小類 總即時功率 (total)
|
||||
let devPath = subSysElecList.filter(x => x.mainSubTag == "total")[0]?.system_device_tag?.split("_").slice(0, 8).join("/");
|
||||
if (devPath) {
|
||||
getElectricMeterNoweDataByBaja(devPath, (data) => {
|
||||
data = data.data;
|
||||
let result = data.filter(x => x.name == "P")[0]?.value;
|
||||
result = result ? result.roundDecimal(2) : 0;
|
||||
totalPow = result;
|
||||
chkBajaLoaded();
|
||||
})
|
||||
}
|
||||
// 每個系統小類 即時功率
|
||||
$.each(subSysElecList, (idx, elecObj) => {
|
||||
let devPath = elecObj.system_device_tag?.split("_").slice(0, 8).join("/");
|
||||
getElectricMeterNoweDataByBaja(devPath, (data) => {
|
||||
data = data.data;
|
||||
let result = data.filter(x => x.name == "P")[0]?.value;
|
||||
result = result ? result.roundDecimal(2) : 0;
|
||||
$(`#insPow${elecObj.mainSubTag}`).text(result);
|
||||
$(`#insPowPer${elecObj.mainSubTag}`).text((result / totalPow * 100).roundDecimal(2) + " %");
|
||||
clearTimeout(lastTimeout);
|
||||
lastTimeout = setTimeout(() => {
|
||||
chkBajaLoaded();
|
||||
}, 10)
|
||||
})
|
||||
|
||||
// 無對應資料系統小類
|
||||
if (idx == subSysElecList.length - 1) {
|
||||
let mainSubTags = subSysElecList.filter(x => x.mainSubTag);
|
||||
$(".elecCard [id^=insPow]").each((idx, ele) => {
|
||||
let tarMainSubTag = $(ele).prop("id").split("insPow")[1];
|
||||
if (mainSubTags.indexOf(tarMainSubTag) == -1) {
|
||||
$(ele).text("---");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
onEvent("click", ".elecCard", function() {
|
||||
let tarMainSubTag = $(this).data("id");
|
||||
|
||||
$("#actSubSysText").text($(this).data("name"));
|
||||
$("#todayElecNoData,#elecCompNoData").hide();
|
||||
$("#todayElecChart,#elecCompChart").parent().show();
|
||||
|
||||
// 空調系統 今日用電量 (每小時)
|
||||
let tarDevNum = subSysElecList.filter(x => x.mainSubTag == tarMainSubTag)[0]?.system_device_tag;
|
||||
if (!tarDevNum) {
|
||||
$("#todayElecNoData,#elecCompNoData").show();
|
||||
$("#todayElecChart,#elecCompChart").parent().hide();
|
||||
elecCompChart?.destroy();
|
||||
todayElecChart?.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
getElectricMeterHourDataByBaja(tarDevNum + "_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"));
|
||||
chartTodaysElec(todayData);
|
||||
chkBajaLoaded();
|
||||
})
|
||||
|
||||
// 空調系統 今日與30日內平均用電比較
|
||||
getElectricMeterDayDataByBaja(tarDevNum + "_KWH", "Mitsubishi_Sup", prevThirtyDay, tomorrow, (data) => {
|
||||
let curDay = (new Date()).getDay() == 0 ? 7 : (new Date()).getDay();
|
||||
let eveWeek = [];
|
||||
let curWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr));
|
||||
|
||||
for (let i = 1; i <= curDay; i++) {
|
||||
let tarDayData = data.data.filter(x => strToDate(x.timestamp.$cEncStr, "day") == i);
|
||||
let tarDayElecs = tarDayData.map(x => x.sum);
|
||||
eveWeek.push(tarDayElecs.sum() / tarDayElecs.length);
|
||||
}
|
||||
|
||||
chartEveWeeksElec(curWeekData, eveWeek)
|
||||
chkBajaLoaded();
|
||||
})
|
||||
})
|
||||
|
||||
$(".elecCard").first().click();
|
||||
|
||||
function chkBajaLoaded() {
|
||||
|
||||
loadedCnt++;
|
||||
if (loadedCnt == 2) {
|
||||
endPageLoading();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 圖表 - 今天用電量 (折線圖)
|
||||
function chartTodaysElec(todayData) {
|
||||
let todayElecChartCanvas = $('#todayElecChart').get(0).getContext('2d');
|
||||
let curHour = (new Date()).getHours();
|
||||
todayData.data = todayData.filter(x => x.timestamp.$time.$hour < curHour);
|
||||
let todayElecChartData = {
|
||||
labels: todayData?.data.map(x => x.timestamp.$time.$hour),
|
||||
datasets: [
|
||||
{
|
||||
type: 'line',
|
||||
label: '今日用電量',
|
||||
fill: false,
|
||||
data: todayData?.data.map(x => x.sum),
|
||||
borderColor: color.success._500,
|
||||
backgroundColor: color.success._500,
|
||||
pointBackgroundColor: color.success._500,
|
||||
|
||||
order: 1,
|
||||
borderWidth: 3,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
let todayElecChartOptions = {
|
||||
maintainAspectRatio: false,
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: true,
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
offset: true,
|
||||
gridLines: { color: color.fusion._500 },
|
||||
ticks: {
|
||||
callback: function (value, index, ticks) {
|
||||
return value
|
||||
}
|
||||
},
|
||||
}],
|
||||
yAxes: [{
|
||||
|
||||
ticks: {
|
||||
min: 0,
|
||||
beginAtZero: true
|
||||
},
|
||||
}]
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
label: function (tooltipItem) {
|
||||
return "用電量 : " + 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.
|
||||
todayElecChart = new Chart(todayElecChartCanvas, {
|
||||
data: todayElecChartData,
|
||||
options: todayElecChartOptions
|
||||
})
|
||||
}
|
||||
|
||||
// 圖表 - 今日與30日內平均用電量比較 (長條圖)
|
||||
function chartEveWeeksElec(curWeekData, avgData) {
|
||||
|
||||
let elecCompChartCanvas = $('#elecCompChart').get(0).getContext('2d');
|
||||
let elecCompChartData = {
|
||||
labels: curWeekData.map(x => dayToChiDay(strToDate(x.timestamp.$cEncStr, "day"))),
|
||||
datasets: [
|
||||
{
|
||||
id: "today",
|
||||
type: "bar",
|
||||
label: '今日用電量',
|
||||
fill: false,
|
||||
backgroundColor: color.success._500,
|
||||
borderColor: color.success._500,
|
||||
pointColor: color.success._500,
|
||||
pointBackgroundColor: color.success._500,
|
||||
data: curWeekData.map(x => x.sum),
|
||||
order: 1,
|
||||
},
|
||||
{
|
||||
id: "avg",
|
||||
type: "bar",
|
||||
label: '30日內平均用電量',
|
||||
fill: false,
|
||||
backgroundColor: color.info._100,
|
||||
borderColor: color.info._100,
|
||||
pointColor: color.info._100,
|
||||
pointBackgroundColor: color.info._100,
|
||||
data: avgData,
|
||||
order: 2,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
let elecCompChartOptions = {
|
||||
maintainAspectRatio: false,
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: true,
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
offset: true,
|
||||
gridLines: { color: color.fusion._500 },
|
||||
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.
|
||||
elecCompChart = new Chart(elecCompChartCanvas, {
|
||||
data: elecCompChartData,
|
||||
options: elecCompChartOptions
|
||||
})
|
||||
}
|
||||
|
||||
onEvent("yt:tab:change", "[data-tabname=energyTab]", function () {
|
||||
let type = $(this).data("id");
|
||||
getSubSysList(type);
|
||||
getElecBySubSysTag();
|
||||
})
|
||||
</script>
|
@ -43,6 +43,21 @@
|
||||
border-top: 0;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.table-compact td{
|
||||
padding:0.2rem 0.3rem;
|
||||
}
|
||||
|
||||
#emerTurn tr td:nth-child(2) {
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#emerTurn tr td:nth-child(1) {
|
||||
width:35%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="d-flex">
|
||||
@ -86,7 +101,7 @@
|
||||
<div id="eleCards" class="row col-12 p-0">
|
||||
|
||||
</div>
|
||||
<div class="mt-2 col-8 p-0">
|
||||
<div class="mt-2 col-8 p-0 d-none">
|
||||
<!--<div class="pl-3 row">
|
||||
<button id="resChartZoom" class="btn btn-info mb-2">圖檔重置</button>
|
||||
</div>-->
|
||||
@ -111,16 +126,49 @@
|
||||
<h4>緊急回轉</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div class="col-12 p-2">
|
||||
<table id="emerTurn" class="table-compact w-100">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label class="mb-0 fs-1-05 w-auto" for="flexRadioDefault1">緊急回歸</label></td>
|
||||
<td><label id="emerReturnText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label></td>
|
||||
<td><span id="emerReturn" class="circle-light bg-secondary"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label class="mb-0 fs-1-05 w-auto" for="flexRadioDefault1">群控故障</label></td>
|
||||
<td><label id="groConFailText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label></td>
|
||||
<td><span id="groConFail" class="circle-light bg-secondary"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label class="mb-0 fs-1-05 w-auto" for="flexRadioDefault1">緊急電源</label></td>
|
||||
<td><label id="emerPowerText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label></td>
|
||||
<td><span id="emerPower" class="circle-light bg-secondary"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label class="mb-0 fs-1-05 w-auto" for="flexRadioDefault1">火災回歸</label></td>
|
||||
<td><label id="fireReturnText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label></td>
|
||||
<td><span id="fireReturn" class="circle-light bg-secondary"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label class="mb-0 fs-1-05 w-auto" for="flexRadioDefault1">地震管制</label></td>
|
||||
<td><label id="earQuaConText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label></td>
|
||||
<td><span id="earQuaCon" class="circle-light bg-secondary"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label class="mb-0 fs-1-05 w-auto" for="flexRadioDefault1">遠端休止</label></td>
|
||||
<td><label id="disResText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label></td>
|
||||
<td><span id="disRes" class="circle-light bg-secondary"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<!--<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
緊急回歸
|
||||
</label>
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">緊急回歸</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="emerReturnText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="emerReturnText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="emerReturn" class="circle-light bg-secondary"></span>
|
||||
@ -128,14 +176,10 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
群控故障
|
||||
</label>
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">群控故障</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="groConFailText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="groConFailText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="groConFail" class="circle-light bg-secondary"></span>
|
||||
@ -143,14 +187,10 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
緊急電源
|
||||
</label>
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">緊急電源</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="emerPowerText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="emerPowerText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="emerPower" class="circle-light bg-secondary"></span>
|
||||
@ -158,14 +198,10 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
火災回歸
|
||||
</label>
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">火災回歸</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="fireReturnText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="fireReturnText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="fireReturn" class="circle-light bg-secondary"></span>
|
||||
@ -173,29 +209,21 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
地震管制
|
||||
</label>
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">地震管制</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="earQuaConText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="earQuaConText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="earQuaCon" class="circle-light bg-secondary"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
遠端休止
|
||||
</label>
|
||||
<div class="">
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">遠端休止</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="disResText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="disResText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="disRes" class="circle-light bg-secondary"></span>
|
||||
@ -203,19 +231,15 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-around mt-2">
|
||||
<div>
|
||||
<label class="form-check-label h4" for="flexRadioDefault1">
|
||||
RET運轉
|
||||
</label>
|
||||
<label class="mb-0 fs-1-05" for="flexRadioDefault1">RET運轉</label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="retOpeText" class="form-check-label h4" for="flexRadioDefault1">
|
||||
未動作
|
||||
</label>
|
||||
<label id="retOpeText" class="mb-0 fs-1-05" for="flexRadioDefault1">未動作</label>
|
||||
</div>
|
||||
<div>
|
||||
<span id="retOpe" class="circle-light bg-secondary"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
<!-- End-右邊功能區 -->
|
||||
<!-- Modal-Card1 -->
|
||||
@ -928,6 +952,27 @@
|
||||
myBaja.setSubscribeDevicesByBql(subOrdPath);
|
||||
myBaja.setSubscribeDevicesCallBack(function (data) {
|
||||
try {
|
||||
if (allDevList.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data.device_number = data.device_number_full;
|
||||
let matchDevice = allDevList.filter(x => x.device_number == data.device_number)[0];
|
||||
let master = matchDevice.device_number.split("_")[5];
|
||||
|
||||
//將訂閱值塞入 subSeviceData
|
||||
if (subSeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) {
|
||||
let obj = {};
|
||||
obj.device_number = matchDevice.device_number;
|
||||
subSeviceData.push(obj)
|
||||
}
|
||||
|
||||
let subData = subSeviceData.filter(x => x.device_number == matchDevice.device_number)[0];
|
||||
|
||||
if (subData) {
|
||||
subData[data.point_name] = data.value;
|
||||
}
|
||||
|
||||
function getValueByName(pointName) {
|
||||
return data.point_name == pointName ? data.value : null;
|
||||
}
|
||||
@ -943,26 +988,23 @@
|
||||
}
|
||||
|
||||
function actLightByPoiEx(pointName1, selector, pointName2, exCond) {
|
||||
$(selector).removeClass("bg-orange").removeClass("bg-red");
|
||||
if (getValueByName(pointName2) == exCond) {
|
||||
if (pointName1 == "falseText") {
|
||||
$(selector).removeClass("bg-orange").removeClass("bg-danger").removeClass("bg-secondary").removeClass("bg-success");
|
||||
$(selector).parent("td").prev().find("label").text("未動作");
|
||||
if (subData[pointName2] == exCond) {
|
||||
if (subData[pointName1] == "falseText") {
|
||||
$(selector).addClass("bg-secondary");
|
||||
$(selector).parent("div").prev().find("label").text("取消控制");
|
||||
$(selector).parent("td").prev().find("label").text("取消控制");
|
||||
} else {
|
||||
$(selector).addClass("bg-red");
|
||||
$(selector).parent("div").prev().find("label").text("控制");
|
||||
$(selector).addClass("bg-danger");
|
||||
$(selector).parent("td").prev().find("label").text("控制");
|
||||
}
|
||||
} else {
|
||||
$(selector).parent("td").prev().find("label").text("休止");
|
||||
$(selector).addClass("bg-success");
|
||||
}
|
||||
}
|
||||
|
||||
if (allDevList.length == 0) {
|
||||
return false;
|
||||
}
|
||||
data.device_number = data.device_number_full;
|
||||
let matchDevice = allDevList.filter(x => x.device_number == data.device_number)[0];
|
||||
let master = matchDevice.device_number.split("_")[5];
|
||||
|
||||
//狀態
|
||||
if (data.point_name == "ST") {
|
||||
$(`#${matchDevice.device_number}_card [name=devStatus]`).text(data.value);
|
||||
@ -1002,6 +1044,7 @@
|
||||
//地震管制
|
||||
actLightByPoi("EER", "#earQuaCon");
|
||||
if (data.point_name == "DNO" || data.point_name == "SP_RCS") {
|
||||
debugger
|
||||
//遠端休止
|
||||
actLightByPoiEx("SP_RCS", "#disRes", "DNO", "trueText");
|
||||
}
|
||||
@ -1011,18 +1054,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
//將訂閱值塞入 subSeviceData
|
||||
if (subSeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) {
|
||||
let obj = {};
|
||||
obj.device_number = matchDevice.device_number;
|
||||
subSeviceData.push(obj)
|
||||
}
|
||||
|
||||
let subData = subSeviceData.filter(x => x.device_number == matchDevice.device_number)[0];
|
||||
|
||||
if (subData) {
|
||||
subData[data.point_name] = data.value;
|
||||
}
|
||||
|
||||
// 設置燈色、卡片閃爍
|
||||
setLightColor();
|
||||
// Card table 更新
|
||||
@ -1038,7 +1070,6 @@
|
||||
}
|
||||
});
|
||||
myBaja.setSubscribeDeviceEndCallBack(function (data) {
|
||||
|
||||
let devNumArr = data.map(x => { return { devNum: x.device_number_full, priority: allDevList.filter(y => y.device_number == x.device_number_full)[0]?.priority } }).DistinctBy("devNum");
|
||||
devNumArr = devNumArr.oSort("priority");
|
||||
$.each(devNumArr, (idx, devObj) => {
|
||||
@ -1142,9 +1173,7 @@
|
||||
|
||||
// Card - 設置列表中訂閱內容
|
||||
function subDeviceSetTable(devNum) {
|
||||
if (allDevList.filter(x => !x.device_number).length > 0) {
|
||||
|
||||
}
|
||||
|
||||
let subData = subSeviceData.filter(x => x.device_number == devNum)[0]
|
||||
let matchDevice = allDevList.filter(x => x.device_number == devNum)[0];
|
||||
if (!subData) {
|
||||
@ -1171,8 +1200,6 @@
|
||||
elevObj.setElevFloor(matchDevice.device_number, subData["CP"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (elev3DObj.length != 0) {
|
||||
let elevObj = elev3DObj.filter(x => x.nodeId == elev3DBind[devNum])[0];
|
||||
if (elevObj && elevObj.id) {
|
||||
|
@ -7,8 +7,19 @@
|
||||
<div class="row m-0 mb-3">
|
||||
<button id="resChartZoom" class="btn btn-info">圖檔重置</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div id="floChart" style="height : 80vh!important;width:100%"></div>
|
||||
</div> -->
|
||||
<!-- <div class="row">
|
||||
<div id="forgeViewer" class="position-absolute" style="width:96%;height:96%;"></div>
|
||||
</div> -->
|
||||
<div class="d-flex">
|
||||
<div class="col-6 my-3">
|
||||
<div id="floChart" style="height : 80vh!important;width:100%"></div>
|
||||
</div>
|
||||
<div class="col-6 my-3">
|
||||
<div id="forgeViewer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -20,6 +31,7 @@
|
||||
var global_emergency_alarm_device_number = [];
|
||||
var zoomToggle = 3;
|
||||
$(function () {
|
||||
show3DModel();
|
||||
initChart();
|
||||
getFloData();
|
||||
})
|
||||
@ -813,4 +825,10 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function show3DModel() {
|
||||
launchViewer("dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxQjFGXzIwMjJfMTJfMDQubndj", (viewer, nodeIds) => {
|
||||
|
||||
});
|
||||
}
|
||||
</script>
|
@ -2281,7 +2281,13 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
})
|
||||
|
||||
endPageLoading();
|
||||
typeof timeOutor != "undefined" ? clearInterval(timeOutor) : ""; // dashboard 定時更新 baja 資料定時器關閉
|
||||
|
||||
if (typeof timeOuters != "undefined") {
|
||||
$.each(timeOuters, (idx, timeOut) => {
|
||||
clearInterval(timeOut);
|
||||
})
|
||||
timeOuters = [];
|
||||
}
|
||||
$("#app").load(`_${page}.html`, loadCallback);
|
||||
|
||||
})
|
||||
|
@ -95,6 +95,26 @@ function launchViewer(urn, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function launchViewerNoTools(urn, callback) {
|
||||
var options = {
|
||||
env: 'AutodeskProduction',
|
||||
getAccessToken: getForgeToken
|
||||
};
|
||||
|
||||
Autodesk.Viewing.Initializer(options, () => {
|
||||
//viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'));
|
||||
viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeViewer'));
|
||||
viewer.start();
|
||||
var documentId = 'urn:' + urn;
|
||||
|
||||
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
|
||||
|
||||
$("#forgeViewer").on("autodesk:loaded", function (e, nodeIds) {
|
||||
callback ? callback(viewer, nodeIds) : "";
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function getAllLeafComponents(viewer, callback) {
|
||||
var cbCount = 0;
|
||||
var tree;
|
||||
|
@ -12,6 +12,78 @@ function addzero(num) {
|
||||
* @param {any} alarmClass
|
||||
* @param {any} callback
|
||||
*/
|
||||
// function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
|
||||
// let _sourceTmp;
|
||||
// var _result = "";
|
||||
// var _ss = "";
|
||||
// var _bfName = "";
|
||||
// var _sourceName = "";
|
||||
// var _index = 0;
|
||||
// var _recoverState = isRecover ? "!= null" : "= null";
|
||||
// var _ackState = isAck ? "= 1" : "!= 1";
|
||||
|
||||
// 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 alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " order by timestamp asc").get()
|
||||
// .then(function (table) {
|
||||
// return table.cursor({
|
||||
// each: function (record) {
|
||||
// _sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
// _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
// _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
// _ss += ', "' + _index + '": {"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
// _index++;
|
||||
// },
|
||||
// after: function () {
|
||||
// _result += '{' + '"count": ' + _index;
|
||||
// _result += _ss;
|
||||
// _result += '}';
|
||||
// if (typeof callback === 'function') {
|
||||
// callback(_result);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
|
||||
// let _sourceTmp;
|
||||
// var _result = "";
|
||||
// var _ss = "";
|
||||
// var _bfName = "";
|
||||
// var _sourceName = "";
|
||||
// var _index = 0;
|
||||
// var _recoverState = isRecover ? "!= null" : "= null"
|
||||
// var _ackState = isAck ? "= 1" : "!= 1";
|
||||
|
||||
// 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 alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " order by timestamp asc").get()
|
||||
// .then(function (table) {
|
||||
// return table.cursor({
|
||||
// each: function (record) {
|
||||
// _sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
// _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
// _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
|
||||
// if (_index == 0)
|
||||
// _ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
// else
|
||||
// _ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
// _index++;
|
||||
// },
|
||||
// after: function () {
|
||||
// _result += '{' + '"count": ' + _index + ', "data":[';
|
||||
// _result += _ss;
|
||||
// _result += ']}';
|
||||
// if (typeof callback === 'function') {
|
||||
// callback(_result);
|
||||
// }
|
||||
// },
|
||||
// limit: -1,
|
||||
// offset: 0
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
|
||||
let _sourceTmp;
|
||||
var _result = "";
|
||||
@ -52,59 +124,40 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得所有異常資料 by baja
|
||||
* @param {any} startDate_millisecond
|
||||
* @param {any} endDate_millisecond
|
||||
* @param {any} isRecover
|
||||
* @param {any} isAck
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
||||
let _sourceTmp;
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _bfName = "";
|
||||
var _sourceName = "";
|
||||
var _index = 0;
|
||||
var _recoverState = isRecover ? "!= null" : "= null";
|
||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("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 timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
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 timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
if (_index == 0)
|
||||
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
else
|
||||
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss + ']';
|
||||
_result += '}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得單一設備最新10筆異常資料 by baja
|
||||
* @param {any} devicePath
|
||||
* @param {any} callback
|
||||
*/
|
||||
// function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||
// var _result = "";
|
||||
// var _ss = "";
|
||||
// var _index = 0;
|
||||
// //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
|
||||
// require(['baja!'], function (baja) {
|
||||
// baja.Ord.make("local:|foxs:|alarm:|bql:select top 10 timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||
// .then(function (table) {
|
||||
// return table.cursor({
|
||||
// each: function (record) {
|
||||
// if (_index == 0)
|
||||
// _ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
|
||||
// else
|
||||
// _ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
|
||||
// _index++;
|
||||
// },
|
||||
// after: function () {
|
||||
// _result += '{' + '"count": ' + _index +', "data":[';
|
||||
|
||||
// _result += _ss+']';
|
||||
// _result += '}';
|
||||
// if (typeof callback === 'function') {
|
||||
// callback(_result);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
@ -152,103 +205,36 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得單一設備異常
|
||||
* @param {any} devicePath
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getOneDeviceAlarmByBaja(devicePath, callback) {
|
||||
let _sourceTmp;
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _bfName = "";
|
||||
var _sourceName = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("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 alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc");
|
||||
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 alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
if (_index == 0)
|
||||
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
else
|
||||
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss + ']';
|
||||
_result += '}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得單一設備異常 有時間、確認、復歸條件
|
||||
* @param {any} devicePath
|
||||
* @param {any} startDate_millisecond
|
||||
* @param {any} endDate_millisecond
|
||||
* @param {any} isRecover
|
||||
* @param {any} isAck
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getOneDeviceAlarmWithTimeByBaja(devicePath, startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
||||
let _sourceTmp;
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _bfName = "";
|
||||
var _sourceName = "";
|
||||
var _index = 0;
|
||||
var _recoverState = isRecover ? "!= null" : "= null";
|
||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("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 alarmData.sourceName like '%" + devicePath + "%' and timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
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 alarmData.sourceName like '%" + devicePath + "%' and timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
if (_index == 0)
|
||||
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
else
|
||||
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss + ']';
|
||||
_result += '}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 在單一系統下,取得各個設備的異常狀態
|
||||
* @param {any} systemPath
|
||||
* @param {any} callback
|
||||
*/
|
||||
// function getOneSystemAlarmStateByBaja(systemPath, callback) {
|
||||
// var _result = "";
|
||||
// var _ss = "";
|
||||
// var _index = 0;
|
||||
|
||||
// require(['baja!'], function (baja) {
|
||||
// baja.Ord.make("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get()
|
||||
// .then(function (table) {
|
||||
// return table.cursor({
|
||||
// each: function (record) {
|
||||
// _ss += ', "' + _index + '": {"uuid":"' + record.get('uuid') + '", "sourceName":"' + record.get('alarmData').get('sourceName') + '", "sourceState":"' + record.get('sourceState') + '"}';
|
||||
// _index++;
|
||||
// },
|
||||
// after: function () {
|
||||
// _result += '{' + '"count": ' + _index;
|
||||
// _result += _ss;
|
||||
// _result += '}';
|
||||
// if (typeof callback === 'function') {
|
||||
// callback(_result);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
function getOneSystemAlarmStateByBaja(systemPath, callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
@ -295,6 +281,10 @@ function getOneSystemStateByBaja(systemPath, callback) {
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
//if (_index == 0)
|
||||
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
//else
|
||||
// _ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
_ss += '{"sourceState":"' + record.get('sourceState') + '"}';
|
||||
_index++;
|
||||
},
|
||||
@ -432,7 +422,7 @@ function getUnCheckedAckedCountByBaja(callback) {
|
||||
function getSystemAlarmByBaja(callback) {
|
||||
var _result = { count: 0, data: [] };
|
||||
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 where isAlarm").get()
|
||||
baja.Ord.make("local:|foxs:|alarm:|bql:select alarmClass where isAlarm").get()
|
||||
@ -441,7 +431,7 @@ function getSystemAlarmByBaja(callback) {
|
||||
each: function (record) {
|
||||
let main = {};
|
||||
main.alarmClass = record.get('alarmClass');
|
||||
|
||||
|
||||
_result.data.push(main);
|
||||
_index++;
|
||||
},
|
||||
@ -457,3 +447,193 @@ function getSystemAlarmByBaja(callback) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 取得單一設備異常
|
||||
// * @param {any} callback
|
||||
// */
|
||||
// //(devicePath, callback)
|
||||
// function getOneDeviceAlarmByBaja(devicePath, startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
||||
// // var _result = "";
|
||||
// // var _ss = "";
|
||||
// // var _occurrenceTime = "";
|
||||
// // var _normalTime = "";
|
||||
// // var _index = 0;
|
||||
|
||||
// let _sourceTmp;
|
||||
// var _result = "";
|
||||
// var _ss = "";
|
||||
// var _bfName = "";
|
||||
// var _sourceName = "";
|
||||
// var _index = 0;
|
||||
// var _recoverState = isRecover ? "!= null" : "= null";
|
||||
// //local:|foxs:|alarm:|bql:select ackState from openAlarms where ackState ='acked'
|
||||
// var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||
|
||||
// //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
|
||||
// require(['baja!'], function (baja) {
|
||||
// console.log("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 alarmData.sourceName like '%" + devicePath + "%' and timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
// 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 alarmData.sourceName like '%" + devicePath + "%' and timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
// // console.log("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 alarmData.sourceName like '%" + devicePath + "%' and alarmClass = '" + alarmClass + "' and timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
// // 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 alarmData.sourceName like '%" + devicePath + "%' and alarmClass = '" + alarmClass + "' and timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
// //baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||
// .then(function (table) {
|
||||
// return table.cursor({
|
||||
// each: function (record) {
|
||||
|
||||
// _sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
// _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
// _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
// // _occurrenceTime = "";
|
||||
// // _normalTime = "";
|
||||
// //var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
|
||||
|
||||
// // var _timestampTemp = new Date(record.get('timestamp').toString());
|
||||
// // _occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
|
||||
|
||||
// // var _normaltime = new Date(record.get('normalTime').toString());
|
||||
// // _normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
|
||||
|
||||
// // var _msgText = record.get('alarmData').get('msgText');// == 1 ? _occurrenceTime : "未確認";
|
||||
// // var _ackText = record.get('ackState') == 1 ? _occurrenceTime : "未確認";
|
||||
|
||||
// //_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
// if (_index == 0)
|
||||
// _ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
// //_ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
||||
// else
|
||||
// _ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
// _index++;
|
||||
// },
|
||||
// after: function () {
|
||||
// _result += '{' + '"count": ' + _index + ', "data":[';
|
||||
// _result += _ss + ']';
|
||||
// _result += '}';
|
||||
// if (typeof callback === 'function') {
|
||||
// callback(_result);
|
||||
// }
|
||||
// },
|
||||
// limit: -1,
|
||||
// offset: 0
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* 取得單一設備異常
|
||||
* @param {any} devicePath
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getOneDeviceAlarmByBaja(devicePath, callback) {
|
||||
let _sourceTmp;
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _bfName = "";
|
||||
var _sourceName = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("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 alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc");
|
||||
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 alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
if (_index == 0)
|
||||
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
else
|
||||
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss + ']';
|
||||
_result += '}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, callback) {
|
||||
let _sourceTmp;
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _bfName = "";
|
||||
var _sourceName = "";
|
||||
var _index = 0;
|
||||
var _recoverState = isRecover ? "!= null" : "= null";
|
||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("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 timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||
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 timestamp.millis >= " + startDate_millisecond + " and timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||
if (_index == 0)
|
||||
_ss += '{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
else
|
||||
_ss += ',{"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss + ']';
|
||||
_result += '}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* [首頁] 圓餅圖資料 - 全部的異常
|
||||
* @param {any} callback
|
||||
*/
|
||||
function getAlarmForChartDataByBaja(callback) {
|
||||
var _result = "";
|
||||
var _ss = "";
|
||||
var _index = 0;
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
baja.Ord.make("local:|foxs:|alarm:|bql:select alarmClass, ackState, normalTime where isAlarm").get()
|
||||
.then(function (table) {
|
||||
return table.cursor({
|
||||
each: function (record) {
|
||||
if (_index == 0)
|
||||
_ss += '{"alarmClass":"' + record.get('alarmClass') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
else
|
||||
_ss += ',{"alarmClass":"' + record.get('alarmClass') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
|
||||
_index++;
|
||||
},
|
||||
after: function () {
|
||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||
_result += _ss;
|
||||
_result += ']}';
|
||||
if (typeof callback === 'function') {
|
||||
callback(_result);
|
||||
}
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -6,6 +6,11 @@ var ordPath; //當前點選選單的tag,用來抓出設備路徑,例如:旅
|
||||
let baja_subscribe_alarm_callback_func; //設定 alarm BQL訂閱之後要回傳的Function
|
||||
let baja_subscribe_end_alarm_callback_func; //設定 alarm BQL訂閱結束之後要回傳的Function
|
||||
var ordPathForAlarm; //當前點選選單的tag,用來抓出alarm路徑
|
||||
|
||||
let baja_subscribe_electricmeter_callback_func;
|
||||
let baja_subscribe_end_electricmeter_callback_func;
|
||||
var ordPathForElectricmeter;
|
||||
|
||||
var startPageLoading; // 開始 loading
|
||||
var endPageLoading; // 開始 loading
|
||||
//window.baja = null;
|
||||
@ -57,6 +62,25 @@ function subscriptionAlarms() {
|
||||
|
||||
}
|
||||
|
||||
function subscriptionElectricmeter() {
|
||||
// 用BQL的方式去訂閱
|
||||
this.setSubscribeElectricmeterByBql = function (tempOrdPath) {
|
||||
BajaSubscribeElectricmeterByBql(tempOrdPath);
|
||||
};
|
||||
// BQL去訂閱回傳的Function
|
||||
this.setSubscribeElectricmeterCallBack = function (callBackFunc) {
|
||||
if (callBackFunc != undefined && callBackFunc != null) {
|
||||
baja_subscribe_electricmeter_callback_func = callBackFunc;
|
||||
}
|
||||
}
|
||||
// BQL訂閱結束回傳的Function
|
||||
this.setSubscribeElectricmeterEndCallBack = function (callBackFunc) {
|
||||
if (callBackFunc != undefined && callBackFunc != null) {
|
||||
baja_subscribe_end_electricmeter_callback_func = callBackFunc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MyBaja() {
|
||||
// 取得使用者帳號
|
||||
this.setMyUserAccount = function (callBackFunc = null) {
|
||||
@ -351,6 +375,154 @@ function BajaSubscribeAlarmsByBql(ordPathForAlarm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用者透過BQL指定路徑去訂閱 electricmeter
|
||||
*/
|
||||
function BajaSubscribeElectricmeterByBql(ordPathForElectricmeter) {
|
||||
|
||||
|
||||
require(['baja!'], function (baja) {
|
||||
console.log("進入Function 準備執行BQL訂閱");
|
||||
startPageLoading ? startPageLoading() : ""
|
||||
var init_start = new Date(Date.now());
|
||||
var sub = new baja.Subscriber();
|
||||
|
||||
sub.attach('changed', function (prop) {
|
||||
if (prop.getName() === 'out') {
|
||||
var out_value = this.getOutDisplay();
|
||||
var target_device_number = this.$parent.getDisplayName().split('_').slice(0, 5).join('_');
|
||||
var point_name = this.getDisplayName();
|
||||
|
||||
//依據Facets判斷回傳的內容值為何
|
||||
var facets_split = this.getFacets1().$cEncStr.split('|');
|
||||
var facets_arr = [];
|
||||
facets_split.forEach(function (item, index) {
|
||||
facets_arr.push(item.split('=s:'));
|
||||
});
|
||||
|
||||
var facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {})
|
||||
|
||||
var point_out_split = this.getOutDisplay().split(' ');
|
||||
|
||||
let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]);
|
||||
|
||||
if (key == undefined) {
|
||||
key = point_out_split[0];
|
||||
}
|
||||
|
||||
var modify_target_device = {
|
||||
"device_number": target_device_number ? target_device_number : null,
|
||||
//"device_number_full": this.$parent.getSlotPath().$names.join("_"),
|
||||
"point_name": point_name ? point_name : null,
|
||||
"value": key
|
||||
}
|
||||
|
||||
if (baja_subscribe_electricmeter_callback_func != undefined && baja_subscribe_electricmeter_callback_func != null) {
|
||||
baja_subscribe_electricmeter_callback_func(modify_target_device, true); //第2參數用在平面圖,刷新畫面
|
||||
}
|
||||
}
|
||||
}, function (err) {
|
||||
console.log(err)
|
||||
});
|
||||
|
||||
//使用bql語法
|
||||
console.log(`local:|foxs:|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`);
|
||||
baja.Ord.make(`local:|foxs:|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`)
|
||||
.get(
|
||||
function (table) {
|
||||
var tableStart, tableFinish;
|
||||
var subStart, subFinish;
|
||||
var component_index = 0;
|
||||
var total_component_index = 0;
|
||||
var totalTargetDevice = [];
|
||||
var readBqlFinish = new Date(Date.now());
|
||||
console.log("讀取路徑完成-花費時間", (readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec");
|
||||
table.cursor({
|
||||
before: function () {
|
||||
totalTargetDevice = [];
|
||||
tableStart = new Date(Date.now());
|
||||
$("#table-start-timestamp").html(tableStart.toISOString());
|
||||
render_start = new Date(Date.now());
|
||||
|
||||
},
|
||||
each: function (item, index) {
|
||||
if (index < 1) {
|
||||
subStart = new Date(Date.now());
|
||||
$("#sub-start").html(subStart.toISOString());
|
||||
}
|
||||
$("#sub-number").html(index + 1);
|
||||
total_component_index = index;
|
||||
|
||||
|
||||
|
||||
var target_device_number_split = this.getDisplay("slotPath").split('/');
|
||||
var target_device_number = target_device_number_split[8];
|
||||
//console.log(target_device_number);
|
||||
var point_name = this.getDisplay("name");
|
||||
var facets = this.getDisplay("facets");
|
||||
|
||||
//依據Facets判斷回傳的內容值為何
|
||||
var facets_split = facets.split(',');
|
||||
var facets_arr = [];
|
||||
facets_split.forEach(function (item, index) {
|
||||
facets_arr.push(item.split('='));
|
||||
});
|
||||
|
||||
facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {})
|
||||
|
||||
var point_out_split = this.getDisplay("out").split(' ');
|
||||
|
||||
let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]);
|
||||
|
||||
if (key == undefined) {
|
||||
key = point_out_split[0];
|
||||
}
|
||||
|
||||
var modify_target_device = {
|
||||
"device_number": target_device_number ? target_device_number : null,
|
||||
//"device_number_full": this.getDisplay("slotPath").split("slot:")[1].split('/').slice(1, -1).join("_"),
|
||||
"point_name": point_name ? point_name : null,
|
||||
"value": key
|
||||
}
|
||||
totalTargetDevice.push(modify_target_device);
|
||||
//取得component當下就更新設備點位
|
||||
if (baja_subscribe_electricmeter_callback_func != undefined && baja_subscribe_electricmeter_callback_func != null) {
|
||||
baja_subscribe_electricmeter_callback_func(modify_target_device);
|
||||
}
|
||||
|
||||
|
||||
baja.Ord.make("local:|foxs:|station:|" + this.getDisplay("slotPath"))
|
||||
.get()
|
||||
.then(function (component) {
|
||||
component_index++;
|
||||
//var target_device_number = component.$parent.getDisplayName().split('_').slice(0, 5).join('_');
|
||||
//var point_name = component.getDisplayName();
|
||||
|
||||
sub.subscribe({
|
||||
comps: component,
|
||||
});
|
||||
tolSubList.push(sub);
|
||||
subFinish = new Date(Date.now());
|
||||
$("#sub-end").html(subFinish.toISOString());
|
||||
$("#sub-time").html((subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
|
||||
// console.log("訂閱完成時間", (subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
|
||||
});
|
||||
},
|
||||
after: function () {
|
||||
tableFinish = new Date(Date.now());
|
||||
if (baja_subscribe_end_electricmeter_callback_func != undefined && baja_subscribe_end_electricmeter_callback_func != null) {
|
||||
baja_subscribe_end_electricmeter_callback_func(totalTargetDevice);
|
||||
}
|
||||
endPageLoading ? endPageLoading() : ""
|
||||
console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec");
|
||||
},
|
||||
limit: -1,
|
||||
offset: 0
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// function getAlarmCountByBaja(callback) {
|
||||
// var _result = "";
|
||||
// var _index = 0;
|
||||
|
@ -171,6 +171,11 @@ function creOption(text = null, value = null, data = {}, attr = {}, cls = [], na
|
||||
return creEle("option", text, id, name, cls, data, attr);
|
||||
}
|
||||
|
||||
function creImg(ele, text = null, id = null, name = null, cls = [], data = {}, attr = {}) {
|
||||
let comp = eleBuild(text, id, name, cls, data, attr);
|
||||
return $(`<${ele} ${comp.attrText}>${comp.text}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根據該棟建築底下的'所有'電梯執行緒物件
|
||||
* */
|
||||
@ -348,3 +353,36 @@ class ElevatorHandler {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 從數字週數轉為中文週數
|
||||
function dayToChiDay(num) {
|
||||
let chiDay = ["週日", "週一", "週二", "週三", "週四", "週五", "週六"];
|
||||
return chiDay[num];
|
||||
}
|
||||
|
||||
// 取得現在或前後時間,輸出單位依據 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;
|
||||
}
|
@ -68,6 +68,12 @@ Array.prototype.oSort = function (key) {
|
||||
}
|
||||
return this.sort(compareNumbers);
|
||||
}
|
||||
|
||||
Array.prototype.sum = function () {
|
||||
return this.reduce(function (a, b) {
|
||||
return a + b;
|
||||
}, 0);
|
||||
}
|
||||
BigInt.prototype.toJSON = function () { return this.toString() }
|
||||
|
||||
$.fn.classList = function () { return this[0].className.split(/\s+/); };
|
||||
|
@ -20,7 +20,7 @@ $(function () {
|
||||
* */
|
||||
function initTabsByEle() {
|
||||
/*_ytTabInited = [];*/
|
||||
$("[data-tabname][data-target]:not([data-tabrole=child])").each(function (index, value) {
|
||||
$("[data-tabname]:not([data-tabrole=child])").each(function (index, value) {
|
||||
let tabName = $(value).data("tabname");
|
||||
if (_ytTabInited.indexOf(tabName) == -1) {
|
||||
var ytTab = new YT.Tab({ tabName: tabName })
|
||||
@ -48,7 +48,7 @@ class YourTeamTab {
|
||||
} else {
|
||||
$(`[data-tabname=${this.tabName}][data-target].active`).first().trigger("click");
|
||||
}
|
||||
|
||||
|
||||
_ytTabInited.push(this.tabName);
|
||||
}
|
||||
|
||||
@ -56,22 +56,24 @@ class YourTeamTab {
|
||||
let clsObj = this;
|
||||
|
||||
// Tab Item 按鈕 click
|
||||
$(`[data-tabname=${this.tabName}][data-target]`).off("click").on("click", function (e) {
|
||||
$(`[data-tabname=${this.tabName}]`).off("click").on("click", function (e) {
|
||||
let target = $(this).data("target");
|
||||
let obj = this;
|
||||
$(`[data-tabname=${clsObj.tabName}][data-target]:not([data-tabrole=child])`).removeClass("active");
|
||||
$(`[data-tabname=${clsObj.tabName}]:not([data-tabrole=child])`).removeClass("active");
|
||||
$(obj).addClass("active");
|
||||
// 觸發 yt:tab:change事件
|
||||
$(obj).trigger("yt:tab:change");
|
||||
let tabName = $(target).data("tabname");
|
||||
if (tabName) {
|
||||
// 找出該觸發對象 block
|
||||
if ($(target).data("tabrole") == "child") {
|
||||
$(obj).trigger("yt:tab:show");
|
||||
$(`[data-tabname='${tabName}'][data-tabrole='child']`).css("opacity", 0).hide();
|
||||
$(target).show().animate({ opacity: 1 }, 200, function () {
|
||||
$(obj).trigger("yt:tab:shown");
|
||||
});
|
||||
if (target) {
|
||||
let tabName = $(target).data("tabname");
|
||||
if (tabName) {
|
||||
// 找出該觸發對象 block
|
||||
if ($(target).data("tabrole") == "child") {
|
||||
$(obj).trigger("yt:tab:show");
|
||||
$(`[data-tabname='${tabName}'][data-tabrole='child']`).css("opacity", 0).hide();
|
||||
$(target).show().animate({ opacity: 1 }, 200, function () {
|
||||
$(obj).trigger("yt:tab:shown");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
267
Frontend/js/yourteam/yourteam.ajax.class_bak.js
Normal file
267
Frontend/js/yourteam/yourteam.ajax.class_bak.js
Normal file
@ -0,0 +1,267 @@
|
||||
var YourTeam = YourTeam || {};
|
||||
/**
|
||||
* This is a description of the Ajax constructor function.
|
||||
* @class Ajax
|
||||
* @classdesc This is a description of the Ajax class.
|
||||
* @author Darren Chen @2021/02/06
|
||||
* @copyright Darren Chen @Your Team Co., Ltd. 2021
|
||||
*/
|
||||
class Ajax {
|
||||
/**
|
||||
* constructor
|
||||
* @constructor
|
||||
* @param {String} apiUrl API URL. def="".
|
||||
* @param {String} sendData the data object which you will be send. def= null.
|
||||
* @param {Fcnction} successFunction successFunction. def=null.(use def successFunction)
|
||||
* @param {Fcnction} errorFunction errorFunction. def=null.(use def successFunction)
|
||||
* @param {String} type HTTP METHOD. def="GET".
|
||||
* @param {Object} conType content type
|
||||
* @param {String} dataType data format. def="JSON".
|
||||
* @param {String} isAsync the api synchronization. def=false.
|
||||
* @return {Object} this
|
||||
*/
|
||||
constructor(apiUrl = "", sendData = null, successFunction = null, errorFunction = null, type = "GET", isAsync = false, conType = this.contentType.Json, dataType = "JSON") {
|
||||
this.conType = conType;
|
||||
this.apiUrl = apiUrl;
|
||||
this.isAsync = isAsync;
|
||||
this.type = type;
|
||||
this.dataType = dataType;
|
||||
this.sendData = sendData;
|
||||
this.extSuccessFunction = successFunction;
|
||||
/*if (successFunction) this.successFunction = successFunction;*/
|
||||
if (errorFunction) this.errorFunction = errorFunction;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* dataToString
|
||||
* @description convert the data object to string
|
||||
* @param {Object} data API URL. def="".
|
||||
* @return {String} strJsonData
|
||||
*/
|
||||
dataToString = function (data) {
|
||||
let strJsonData = data ? (data.Data ? JSON.stringify(data.Data) : null) : null;
|
||||
return strJsonData;
|
||||
}
|
||||
/**
|
||||
* beforeSendFunction
|
||||
* @description beforeSendFunction
|
||||
*/
|
||||
beforeSendFunction = function (xhr) {
|
||||
let token = localStorage.getItem("JWT-Authorization");
|
||||
xhr.setRequestHeader('Authorization', "Bearer " + token);
|
||||
}
|
||||
/**
|
||||
* successFunction
|
||||
* @description successFunction
|
||||
* @param {Object} data the data object from the api return
|
||||
* @return {Object} data
|
||||
*/
|
||||
successFunction = function (data, callback) {
|
||||
debugger
|
||||
if (data && data.unauthorized == 401) {
|
||||
let href = location.href;
|
||||
localStorage.removeItem("JWT-Authorization");
|
||||
if (href.indexOf("localhost:5966") == -1) {
|
||||
location.href = "/login";
|
||||
} else {
|
||||
location.href = "login.html";
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* errorFunction
|
||||
* @description errorFunction
|
||||
* @param {Object} xhr HTTP STATUS
|
||||
* @param {Object} ajaxOptions the ajax option message
|
||||
* @param {String} thrownError the error message
|
||||
*/
|
||||
errorFunction = function (xhr, ajaxOptions, thrownError) {
|
||||
if (xhr.status != "201" && xhr.status != "204") {
|
||||
console.log(xhr.status);
|
||||
console.log(thrownError);
|
||||
window.alert("執行失敗,請聯絡客服人員。");
|
||||
} else if (xhr.status == "401") {
|
||||
window.alert("登入時間超時,請重新登入!");
|
||||
localStorage.removeItem("JWT-Authorization");
|
||||
location.href = "~/Login/Login";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* completeFunction
|
||||
* @description completeFunction
|
||||
*/
|
||||
completeFunction = function () {
|
||||
|
||||
}
|
||||
/**
|
||||
* content type
|
||||
* @description content type
|
||||
*/
|
||||
contentType = {
|
||||
Json: 1,
|
||||
FormData : 2
|
||||
}
|
||||
/**
|
||||
* enum
|
||||
* @description enum
|
||||
* @param {Object} eo object
|
||||
* @return {Object} enum
|
||||
*/
|
||||
enums(eo) {
|
||||
var enums = function () { };
|
||||
for (var key in eo) {
|
||||
var enumObject = new enums();
|
||||
enums[key] = eo[key];
|
||||
}
|
||||
return enums;
|
||||
}
|
||||
/**
|
||||
* send
|
||||
* @description send
|
||||
* @param {Object} conType content type
|
||||
* @param {Object} sendData send data
|
||||
* @param {Function} successFunction the ajax success function
|
||||
* @param {Function} errorFunction the ajax error function
|
||||
* @return {Object} this
|
||||
*/
|
||||
send = function (conType = this.contentType.Json, sendData = null, successFunction = null, errorFunction = null) {
|
||||
|
||||
//if (!CheckMultiSend(this.apiUrl, this.type, this.dataToString(this.sendData))) { //連點防呆
|
||||
// return false;
|
||||
//}
|
||||
if (sendData) {
|
||||
this.sendData = sendData;
|
||||
}
|
||||
if (successFunction) {
|
||||
this.successFunction = successFunction;
|
||||
}
|
||||
if (errorFunction) {
|
||||
this.errorFunction = errorFunction;
|
||||
}
|
||||
if (conType === this.contentType.Json) {
|
||||
$.ajax({
|
||||
url: this.apiUrl,
|
||||
async: this.isAsync,
|
||||
type: this.type,
|
||||
dataType: this.dataType,
|
||||
traditional: true,
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: this.dataToString(this.sendData),
|
||||
|
||||
//cache: false,
|
||||
//processData: false,
|
||||
|
||||
beforeSend: this.beforeSendFunction,
|
||||
success: (data) => this.successFunction(data, this.extSuccessFunction),
|
||||
error: this.errorFunction,
|
||||
complete: this.completeFunction,
|
||||
statusCode: {
|
||||
201: (data) => this.successFunction(data, this.extSuccessFunction),
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (conType === this.contentType.FormData) {
|
||||
$.ajax({
|
||||
url: this.apiUrl,
|
||||
async: this.isAsync,
|
||||
type: this.type,
|
||||
dataType: this.dataType,
|
||||
|
||||
traditional: true,
|
||||
|
||||
contentType: false,
|
||||
enctype: 'multipart/form-data',
|
||||
data: this.sendData,
|
||||
cache: false,
|
||||
processData: false,
|
||||
beforeSend: this.beforeSendFunction,
|
||||
success: this.successFunction,
|
||||
error: this.errorFunction,
|
||||
complete: this.completeFunction
|
||||
});
|
||||
alert(conType);
|
||||
}
|
||||
else {
|
||||
console.error("the content type is null.");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
YourTeam.Ajax = YourTeam.Ajax || Ajax;
|
||||
|
||||
var ckeckMultiSendArr = [];
|
||||
function CheckMultiSend(url, type, data) {
|
||||
//根據 url type data
|
||||
let text = String(url) + String(type);
|
||||
if (type != "GET") {
|
||||
if (ckeckMultiSendArr.indexOf(text) == -1) {
|
||||
ckeckMultiSendArr.unshift(text);
|
||||
let timer = setInterval(function () {
|
||||
ckeckMultiSendArr.splice(0);
|
||||
clearInterval(timer);
|
||||
}, 500)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//var YourTeamAjax = {
|
||||
// apiUrl: "",
|
||||
// isAsync: false,
|
||||
// type: "GET",
|
||||
// dataType: "JSON",
|
||||
// sendData: null,
|
||||
// dataToString: function (data) {
|
||||
// let strJsonData = data ? (data.Data ? JSON.stringify(data.Data) : null) : null;
|
||||
// return strJsonData;
|
||||
// },
|
||||
// beforeSendFunction: function () {
|
||||
// $.blockUI({ message: '<h1><img src="/Content/img/loading.gif" style="width:200px;" /> Loding...</h1>' });
|
||||
// },
|
||||
// successFunction: function (data) {
|
||||
// return data;
|
||||
// },
|
||||
// errorFunction: function (xhr, ajaxOptions, thrownError) {
|
||||
// if (xhr.status != "201") {
|
||||
// console.log(xhr.status);
|
||||
// console.log(thrownError);
|
||||
// window.alert("執行失敗,請聯絡YourTeam客服人員。");
|
||||
// }
|
||||
// },
|
||||
// completeFunction: function () {
|
||||
// $.unblockUI();
|
||||
// },
|
||||
// send: function (sendData = null, successFunction = null, errorFunction = null) {
|
||||
// if (sendData) {
|
||||
// this.sendData = sendData;
|
||||
// }
|
||||
// if (successFunction) {
|
||||
// this.successFunction = successFunction;
|
||||
// }
|
||||
// if (errorFunction) {
|
||||
// this.errorFunction = errorFunction;
|
||||
// }
|
||||
// $.ajax({
|
||||
// url: this.apiUrl,
|
||||
// async: this.isAsync,
|
||||
// type: this.type,
|
||||
// dataType: this.dataType,
|
||||
// traditional: true,
|
||||
// contentType: "application/json; charset=utf-8",
|
||||
// data: this.dataToString(this.sendData),
|
||||
// beforeSend: this.beforeSendFunction,
|
||||
// success: this.successFunction,
|
||||
// error: this.errorFunction,
|
||||
// complete: this.completeFunction,
|
||||
// statusCode: {
|
||||
// 201: this.successFunction
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//};
|
@ -491,9 +491,56 @@ class File {
|
||||
let myMath = new YourTeam.Utility.Math();
|
||||
let myFile = new YourTeam.Utility.File();
|
||||
let strExtName = "", strOrgName = "";
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
|
||||
if (files.length > 0) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
if (limitMaxSize != null) {
|
||||
if (file.size / 1024 < limitMinSize || file.size / 1024 > limitMaxSize) {
|
||||
limitFun ? limitFun() : "";
|
||||
return false
|
||||
}
|
||||
}
|
||||
htmlImg = "";
|
||||
let guid = myMath.guid().replace(' ', '');
|
||||
file.guid = guid;
|
||||
if (/\.(jpe?g|png|gif)$/i.test(file.name)) {
|
||||
let reader = new FileReader();
|
||||
reader.addEventListener("load", function () {
|
||||
let image = new Image();
|
||||
let src = this.result;
|
||||
image.src = this.result;
|
||||
image.onload = function () {
|
||||
strExtName = myFile.getFileExtension(file.name);
|
||||
strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, '');
|
||||
htmlImg = frontHtml + '<img data-filename="' + file.name + '" data-orgname="' + strOrgName + '" data-savename="' + guid + '" data-extname="' + strExtName
|
||||
+ '" data-size="' + file.size + '" width="' + width + '" height="' + height + '" src="' + src + '">'
|
||||
+ backHtml;
|
||||
|
||||
container.insertAdjacentHTML("afterBegin", htmlImg);
|
||||
//$("[name=" + removeClickTagName + "]").on("click", function (e) {
|
||||
// e.preventDefault();
|
||||
// $(this).closest(removeTag).remove();
|
||||
//});
|
||||
if (i === files.length - 1 && funDoSomeThing) {
|
||||
funDoSomeThing();
|
||||
}
|
||||
}
|
||||
});
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
if (showAlert) {
|
||||
showAlert("danger", "只支援圖片格式");
|
||||
}
|
||||
else {
|
||||
alert("只支援圖片格式");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
let file = files;
|
||||
if (limitMaxSize != null) {
|
||||
if (file.size / 1024 < limitMinSize || file.size / 1024 > limitMaxSize) {
|
||||
limitFun ? limitFun() : "";
|
||||
@ -504,7 +551,6 @@ class File {
|
||||
let guid = myMath.guid().replace(' ', '');
|
||||
file.guid = guid;
|
||||
if (/\.(jpe?g|png|gif)$/i.test(file.name)) {
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.addEventListener("load", function () {
|
||||
let image = new Image();
|
||||
@ -522,21 +568,21 @@ class File {
|
||||
// e.preventDefault();
|
||||
// $(this).closest(removeTag).remove();
|
||||
//});
|
||||
if (i === files.length - 1 && funDoSomeThing) {
|
||||
if (funDoSomeThing) {
|
||||
funDoSomeThing();
|
||||
}
|
||||
}
|
||||
});
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
if (showAlert) {
|
||||
if (showAlert) {
|
||||
showAlert("danger", "只支援圖片格式");
|
||||
}
|
||||
else {
|
||||
alert("只支援圖片格式");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readAndPreviewFiles(files, containerId, imgWidth = null, imgHeight = null, frontHtml = null, backHtml = null, funDoSomeThing = null) {
|
||||
@ -547,37 +593,82 @@ class File {
|
||||
let myMath = new YourTeam.Utility.Math();
|
||||
let myFile = new YourTeam.Utility.File();
|
||||
let strExtName = "", strOrgName = "", strSaveName = "";
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
|
||||
if (files.length) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
htmlImg = "";
|
||||
|
||||
let guid = myMath.guid().replace(' ', '');
|
||||
file.guid = guid;
|
||||
//alert(/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name));
|
||||
if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)) {
|
||||
|
||||
if (file.size == 0) { //檔案大小為0時不會產生base64,需防呆
|
||||
showAlert("danger", "無法上傳大小為0的檔案");
|
||||
return false;
|
||||
}
|
||||
|
||||
//先新增a標籤 在套上src 可能解決多檔案上傳時無法讀取到最後上傳檔案的問題
|
||||
strSaveName = guid;
|
||||
strExtName = myFile.getFileExtension(file.name);
|
||||
strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, '');
|
||||
|
||||
htmlImg = frontHtml + '<a id="' + strSaveName + '" data-filename="' + file.name + '" data-orgname="' + strOrgName + '" data-savename="' + strSaveName + '" data-extname="' + strExtName
|
||||
+ '" data-size="' + file.size + '" width="' + width + '" height="' + height + '" download="' + strOrgName + '.' + strExtName + '" target="_blank">' + strOrgName + '.' + strExtName + '</a>'
|
||||
+ backHtml;
|
||||
container.insertAdjacentHTML("afterBegin", htmlImg);
|
||||
let reader = new FileReader();
|
||||
|
||||
reader.addEventListener("load", function (event) {
|
||||
$($(container).find("a")[i]).attr("href", this.result);
|
||||
if (i === files.length - 1 && funDoSomeThing) {
|
||||
funDoSomeThing();
|
||||
}
|
||||
});
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
} else {
|
||||
if (showAlert) {
|
||||
showAlert("danger", "只支援文件格式");
|
||||
} else {
|
||||
alert("只支援文件格式");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
let file = files;
|
||||
htmlImg = "";
|
||||
|
||||
let guid = myMath.guid().replace(' ', '');
|
||||
file.guid = guid;
|
||||
//alert(/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name));
|
||||
if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)) {
|
||||
|
||||
if (file.size == 0) { //檔案大小為0時不會產生base64,需防呆
|
||||
showAlert("danger", "無法上傳大小為0的檔案");
|
||||
return false;
|
||||
}
|
||||
|
||||
//先新增a標籤 在套上src 可能解決多檔案上傳時無法讀取到最後上傳檔案的問題
|
||||
strSaveName = myMath.guid().replace(' ', '');
|
||||
strSaveName = guid;
|
||||
strExtName = myFile.getFileExtension(file.name);
|
||||
strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, '');
|
||||
|
||||
htmlImg = frontHtml + '<a id="' + strSaveName +'" data-filename="' + file.name + '" data-orgname="' + strOrgName + '" data-savename="' + strSaveName + '" data-extname="' + strExtName
|
||||
+ '" data-size="' + file.size + '" width="' + width + '" height="' + height +'" download="' + strOrgName + '.' + strExtName + '" target="_blank">' + strOrgName + '.' + strExtName + '</a>'
|
||||
|
||||
htmlImg = frontHtml + '<a id="' + strSaveName + '" data-filename="' + file.name + '" data-orgname="' + strOrgName + '" data-savename="' + strSaveName + '" data-extname="' + strExtName
|
||||
+ '" data-size="' + file.size + '" width="' + width + '" height="' + height + '" download="' + strOrgName + '.' + strExtName + '" target="_blank">' + strOrgName + '.' + strExtName + '</a>'
|
||||
+ backHtml;
|
||||
container.insertAdjacentHTML("afterBegin", htmlImg);
|
||||
let reader = new FileReader();
|
||||
|
||||
reader.addEventListener("load", function (event) {
|
||||
$($(container).find("a")[i]).attr("href", this.result);
|
||||
if (i === files.length - 1 && funDoSomeThing) {
|
||||
$($(container).find("a")).attr("href", this.result);
|
||||
if (funDoSomeThing) {
|
||||
funDoSomeThing();
|
||||
}
|
||||
});
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
|
||||
} else {
|
||||
if (showAlert) {
|
||||
showAlert("danger", "只支援文件格式");
|
||||
@ -585,7 +676,7 @@ class File {
|
||||
alert("只支援文件格式");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async getBase64Image(path, callback) {
|
||||
//生成canvas
|
||||
|
Loading…
Reference in New Issue
Block a user