[Frontend][儀錶板] 昨日用電量、今日用電量、即時功率 baja 串接 | [系統監控] 電梯 3D 移動 第二次之後不動問題解決

This commit is contained in:
dev01 2022-12-03 16:45:20 +08:00
parent 38e81cd8c2
commit 22e68815a6
6 changed files with 479 additions and 457 deletions

View File

@ -9,7 +9,7 @@
<div class="p-3 bg-primary-300 rounded overflow-hidden position-relative text-white mb-g">
<div class="">
<h3 class="display-4 d-block l-h-n m-0 fw-500">
560
<span id="todayUseElec"></span>
<small class="m-0 l-h-n">今日用電量 kWH</small>
</h3>
</div>
@ -20,7 +20,7 @@
<div class="p-3 bg-warning-400 rounded overflow-hidden position-relative text-white mb-g">
<div class="">
<h3 class="display-4 d-block l-h-n m-0 fw-500">
6560
<span id="yesUseElec"></span>
<small class="m-0 l-h-n">昨日用電量</small>
</h3>
</div>
@ -69,7 +69,7 @@
<div class="p-3 bg-success-200 rounded overflow-hidden position-relative text-white mb-g">
<div class="">
<h3 class="display-4 d-block l-h-n m-0 fw-500">
9,218
<span id="insPower"></span>
<small class="m-0 l-h-n">即時功率</small>
</h3>
</div>
@ -162,7 +162,7 @@
</h2>
</div>
<div class="panel-container show">
<div class="panel-content poisition-relative">
<div class="panel-content poisition-relative p-0">
<!--<div class="pb-5 pt-3">
<div class="d-flex mr-4">
<div class="mr-2">
@ -174,15 +174,15 @@
</div>
</div>
</div>-->
<div class="col-12 mb-2 position-relative">
<span class="text-center position-absolute t-white" style="top:83px;left:45px;">異常數量<br>18</span>
<img src="img/u110.png" class="w-100">
<span class="text-center position-absolute t-white" style="top:116px;left:142px;">賦歸數量<br>28</span>
<div class="col-12 mb-2 position-relative row m-0 justify-content-center">
<span class="text-center position-absolute t-white" style="top:25%;left:27%;">異常數量<br>18</span>
<img src="img/u110.png" class="w-50">
<span class="text-center position-absolute t-white" style="top:42%;left:51%;">賦歸數量<br>28</span>
</div>
<div class="col-12 mb-2 position-relative">
<span class="text-center position-absolute t-white" style="top:120px;left:37px;">已確認異常<br>8</span>
<img src="img/u106.png" class="w-100">
<span class="text-center position-absolute t-white" style="top:100px;left:140px;">未確認異常<br>6</span>
<div class="col-12 mb-2 position-relative row m-0 justify-content-center">
<span class="text-center position-absolute t-white" style="top:43%;left:24%;">已確認異常<br>8</span>
<img src="img/u106.png" class="w-50">
<span class="text-center position-absolute t-white" style="top:35%;left:52%;">未確認異常<br>6</span>
</div>
</div>
</div>
@ -196,7 +196,7 @@
</h2>
</div>
<div class="panel-container show">
<div class="panel-content poisition-relative">
<div class="panel-content poisition-relative p-0">
<!--<div class="pb-5 pt-3">
<div class="d-flex mr-0">
<div class="mr-2">
@ -208,15 +208,15 @@
</div>
</div>
</div>-->
<div class="col-12 mb-2 position-relative">
<span class="text-center position-absolute t-white" style="top:27px;left:55px;">已完成<br>6</span>
<img src="img/u40.png" class="" style="width:312px;margin-left:-45px;left:-22px;">
<span class="text-center position-absolute t-white" style="top:114px;left:162px;">未完成<br>8</span>
<div class="col-12 mb-2 position-relative row m-0 justify-content-center">
<span class="text-center position-absolute t-white" style="top:25%;left:27%;">已完成<br>6</span>
<img src="img/u40.png" class="" style="width:75%;margin-left:0px;left:-22px;">
<span class="text-center position-absolute t-white" style="top:51%;left:58%;">未完成<br>8</span>
</div>
<div class="col-12 mb-2 position-relative">
<span class="text-center position-absolute t-white" style="top:89px;left:27px;">未派工<br>5</span>
<img src="img/u43.png" class="w-100">
<span class="text-center position-absolute t-white" style="top:122px;left:177px;">派工中<br>9</span>
<div class="col-12 mb-2 position-relative row m-0 justify-content-center">
<span class="text-center position-absolute t-white" style="top:43%;left:26%;">未派工<br>5</span>
<img src="img/u43.png" class="mt-2 mb-1" style="width:51%;">
<span class="text-center position-absolute t-white" style="top:42%;left:58%;">派工中<br>9</span>
</div>
</div>
</div>
@ -699,8 +699,8 @@
let strHtml = ``;
$.each(res.data.history_Main_Systems, (index, mainSysObj) => {
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
strHtml += `<div class="btn-group btn-group-lg col-lg-4 mb-4 dev-group" data-id="/${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}">
<button type="button" class="btn btn-secondary col-4"><i class="fal fa-lightbulb-on fa-2x"></i></button>
strHtml += `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group" data-id="/${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}">
<button type="button" class="btn btn-secondary col-4"><i class="fal fa-lightbulb-on fa-2x py-2"></i></button>
<button type="button" class="btn btn-secondary">${subSysObj.full_name}</button>
</div>`;
})
@ -736,13 +736,28 @@
}
function getElectricBaja() {
let devPath = tarElePath.split("_").slice(0, 8).join("_");
let devNum = tarElePath.split("_").slice(0, 8).join("_");
let devPath = tarElePath.split("_").slice(0, 8).join("/");
let today = displayDate(new Date, "date").replaceAll("/", "-") + "T00:00:00";
let yesterday = displayDate(new Date(new Date(today).getTime() - (24 * 60 * 60 * 1000)), "date").replaceAll("/", "-") + "T00:00:00";
let tomorrow = displayDate(new Date(new Date(today).getTime() + (24 * 60 * 60 * 1000)), "date").replaceAll("/", "-") + "T00:00:00";
getElectricMeterDayDataByBaja(devPath + "_KWH", "Mitsubishi_Sup", today, tomorrow, (data) => {
//今日用電量
getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", today, tomorrow, (data) => {
data = JSON.parse(data);
$("#todayUseElec").text(data?.data[0]?.sum || "");
})
//昨日用電量
getElectricMeterDayDataByBaja(devNum + "_KWH", "Mitsubishi_Sup", yesterday, today, (data) => {
data = JSON.parse(data);
$("#yesUseElec").text(data?.data[0]?.sum || "");
})
getElectricMeterNoweDataByBaja(devPath, (data) => {
console.log(data)
data = data.data;
$("#insPower").text(data.filter(x => x.name == "P")[0]?.value);
})
}

View File

@ -861,7 +861,7 @@
var subSeviceData = []; //每個設備訂閱點位值
var floList = []; //每個樓層
var elevObj = null; //左側 2D 電梯物件
var viewer3DNodeIds = [758, 753, 748];
var viewer3DNodeIds = [760, 754, 748];
var elev3DBind = {};
var elev3DOption = {};
var elev3DObj = [];
@ -897,7 +897,6 @@
myBaja = new subscriptionDevices();
myBaja.setSubscribeDevicesByBql(subOrdPath);
myBaja.setSubscribeDevicesCallBack(function (data) {
console.log(data)
function getValueByName(pointName) {
return data.point_name == pointName ? data.value : null;
}
@ -1021,9 +1020,10 @@
elevObj.obj = Object.assign(elevObj.obj, elev3DOption);
elevObj.obj.init(function () {
let frags = elevObj.obj.fragProxys.filter(x => x.nodeId == elev3DBind[devNum]);
debugger
frags.forEach((fragProxy) => {
fragProxy.frag.position.z = elev3DOption.floorHeight.filter(x => x.floor == subData["CP"])[0]?.height ?? 0;
fragProxy.frag.updateAnimTransform()
fragProxy.frag.updateAnimTransform();
})
elevObj.obj.viewer.impl.sceneUpdated(true);
});
@ -1078,7 +1078,7 @@
})
}
})
console.log("result:", result)
/*console.log("result:", result)*/
return result;
}
@ -1124,6 +1124,7 @@
if (subData["CP"]) {
$(`#imdStaTable_${devNum} [name=curFloor]`).text(subData["CP"]);
}
console.log("目標樓層:" + subData["CP"], "RD點位值:" + subData["RD"])
//往上或往下
if (subData["RD"] == "UP") {
$(`#imdStaTable_${devNum} [name=downFloArrow]`).removeClass("light-flash-c");
@ -1874,7 +1875,7 @@
//myBaja.setSubscribeDevicesByBql(ordPath);
//myBaja.setSubscribeDevicesCallBack(subscribeCallBack);
console.log(floChart)
/*console.log(floChart)*/
floChart.getZr().on('click', function (params) {
console.log("click", params);
var pixelPoint = [params.offsetX, params.offsetY];
@ -2422,6 +2423,7 @@
elevObj.obj = Object.assign(elevObj, elevator3DObj ?? {})
elevObj.obj.init(function () {
let frags = elevObj.obj.fragProxys.filter(x => x.nodeId == node);
debugger
frags.forEach((fragProxy) => {
fragProxy.frag.position.z = elev3DOption.floorHeight.filter(x => x.floor == subData["CP"])[0]?.height ?? 0;
fragProxy.frag.updateAnimTransform()

View File

@ -2092,202 +2092,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
// 執行初步 Loading
var loadEle = pageLoading();
$(function () {
// 二次引用 jquery.js
// - 在 require 內部程序需要引用 jquery由於 require 的套件需要依賴 jquery ,就算 HTML 已經引用 jquery require 也無法參考
// - 上方 HTML 引用套件若有使用 jquery 內存數據程序 (ex: $(x).data() , $(x).trigger("custom event") , $.fn.custom ...)
// - 會被清洗,有類似程序需放入 loadPack1 Function rquired 引用
// (原 datatable.bundle.js require 會出問題,先以 cdn datatable.min.js引用)
require(["jquery"], loadedBasePack);
})
/**
* jquery.js 二次引用後 Callback載入第三方套件
* */
function loadedBasePack() {
require(
[
"lib/app.bundle",
"lib/app.menu",
"datatables.net.b4",
"n4js/alarmbaja",
"n4js/historybaja",
"lib/statistics/flot/flot.bundle",
"lib/statistics/peity/peity.bundle",
], loadedMasterPack);
}
/**
* 第三方套件引用後 Callback載入額外套件
* */
function loadedMasterPack() {
require(
[
"yourteam/yourteam.ajax.class",
"yourteam/yourteam.utility.class",
"yourteam/yourteam.jquery.datatables",
"yourteam/plugins/yt-tooltip/yt-tooltip",
"yourteam/plugins/yt-tab/yt-tab",
"style",
], function () {
require(["init", "site"], loadedJsPack)
});
}
/**
* 全數套件讀取完成 Callback
* */
function loadedJsPack() {
loadEvent();
if (!jwt) {
myBaja = new MyBaja();
myBaja.setMyUserAccount(Login);
} else {
isValidLogin();
}
$(loadEle).Loading("close");
}
/**
* 登入驗證完成 Callback
* */
function isValidLogin() {
$("#app").load("_dashboard.html", loadCallback);
getBuiList();
getSysMonBtnList();
checkDevState();
function getSysMonBtnList() {
let url = baseApiUrl + "/api/Device/GetMainSub";
let sendData = {
building_tag: pageAct.buiTag,
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$("#sysMonBtnList").html()
$.each(res.data.history_Main_Systems, (index, mainSysObj) => {
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
let page = "systemMonitor";
if (subSysObj.sub_system_tag == "EL") {
page = "sysElevator";
}
let btn = creBtn(subSysObj.full_name, `subSysBtn${subSysObj.sub_system_tag}`, "topFunBtn", ["dropdown-item"], { page: page });
subSysObj.main_system_tag = mainSysObj.main_system_tag;
btn.data("subSysObj", subSysObj);
$("#sysMonBtnList").append(btn);
})
})
}
}, null, "POST").send();
}
function getBuiList() {
let url = baseApiUrl + "/api/Device/GetBuild";
ytAjax = new YourTeam.Ajax(url, null, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
let strHtml = ``;
$.each(res.data, (index, buiObj) => {
strHtml += `<a id="buiBtn${buiObj.building_tag}" class="dropdown-item" href="javascript:;">${buiObj.full_name}</a>`;
})
$("#buiList").append(strHtml).droSetItem(); //droSetItem 預設第一筆 active
}
}, null, "POST").send();
}
//lily test
function checkDevState() {
//TPE_B1_LT_L1
//main_system_tag: pageAct.sysMainTag,
//building_tag: pageAct.buiTag,
//floor_tag: pageAct.floTag,
let systemPath = "TPE_B1";
// if (pageAct != undefined && pageAct != null && pageAct.sysMainTag != null && pageAct.buiTag != null) {
// systemPath = "TPE_" + pageAct.buiTag + "_" + pageAct.sysMainTag + "_" + "EL";
// }
getOneSystemAlarmStateByBaja(systemPath, callbackForCheckDevState);
// console.log("systemP: " + systemPath);
// console.log("devList: " + deviceList[0].device_guid + ", " + deviceList[3].device_guid + ", " + deviceList[8].device_guid);
//callbackForCheckDevState("test");
}
function callbackForCheckDevState(result) {
console.log("------ " + result);
// $.each(deviceList, (index, devObj) => {
// if ((`${devObj.device_guid}`) == '4ed28a93-5025-11ed-b23e-0242ac110002'
// || (`${devObj.device_guid}`) == '5d9fdff0-5343-43fe-86f4-bd73cdb15111') {
// var str = "";
// $(`#${devObj.device_guid}`).empty();
// str = `<span class="status status-danger d-inline-block"><img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="..."></span> ${devObj.full_name}`;
// $(`#${devObj.device_guid}`).append(str);
// }
// })
console.log(result);
}
}
// page loaded callback
function loadCallback() {
initTabsByEle();
resetYTTooltip();
}
// 事件先行讀取
function loadEvent() {
onEvent("click", "[name=topFunBtn]", function () {
let needLoad = ["sysElevator","historyData"];
_ytTabInited = [];
let page = $(this).data("page");
if (page != "systemMonitor") {
$("#sysMonBtnList .dropdown-item").removeClass("active");
pageAct.sysMainTag = null;
}
$.each(tolSubList, (idx, sub) => {
console.log("sub", sub, idx)
sub.unsubscribeAll();
sub.detach();
})
$("#app").load(`_${page}.html`, loadCallback);
// 需要 Loading 的頁面
if (needLoad.indexOf(page) != -1) {
$(loadEle).Loading("start", "資料讀取中...");
}
})
onEvent("click", "#logout", function () {
localStorage.removeItem("JWT-Authorization");
location.href = "/logout";
})
onEvent("active:change", "#sysMonBtnList", function (e, actEle) {
if (actEle) {
pageAct.sysMainTag = $(actEle).data("subSysObj").main_system_tag;
pageAct.sysSubTag = $(actEle).data("subSysObj").sub_system_tag;
pageAct.sysSubName = $(actEle).data("subSysObj").full_name;
pageAct.sysSubObj = $(actEle).data("subSysObj");
}
})
onEvent("active:change", "#buiList", function (e, actEle) {
if (actEle) {
pageAct.buiTag = $(actEle).prop("id").split("buiBtn")[1];
}
})
}
/**
* 頁面 Loading 建立
@ -2302,103 +2106,300 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
return background;
}
// 登入驗證
function Login(account) {
console.log(account)
/*if ($("#login-form").valid()) {*/
var url = baseApiUrl + "/api/Login/";
var send_data = {
account: account,
password: "rJ2T5Kkj"
}
if (location.href.indexOf("localhost:5966") != -1) {
location.href = "login.html";
}
$.ajax({
method: "post",
url: url,
data: JSON.stringify(send_data),
async: false,
contentType: "application/json; charset=UTF-8",
dataType: 'json',
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg || "系統內部發生錯誤,請聯絡系統管理員");
return;
}
else {
/*toast_ok(rel.msg);*/
localStorage.setItem('JWT-Authorization', rel.data.token);
isValidLogin();
}
},
error: function (xhr, textStatus, thrownError) {
alert(textStatus);
}
});
}
//==============================================================================
// ↓ 系統監控 - 共用 Function ↓
//==============================================================================
// Card - 基本資料 Table
function drawInfoTabBlo(devGuid) {
let tabEle = $(`<table class="table table-bordered table-striped text-center m-0">`);
let tbody = tabEle.append("<tbody>");
let columnNames = ["設備編號", "設備名稱"];
$.each(columnNames, (index, colName) => {
let tr = $("<tr></tr>");
let td = $("<td></td>");
td.text(colName);
tr.append(td);
tbody.append(tr);
try {
$(function () {
// 二次引用 jquery.js
// - 在 require 內部程序需要引用 jquery由於 require 的套件需要依賴 jquery ,就算 HTML 已經引用 jquery require 也無法參考
// - 上方 HTML 引用套件若有使用 jquery 內存數據程序 (ex: $(x).data() , $(x).trigger("custom event") , $.fn.custom ...)
// - 會被清洗,有類似程序需放入 loadPack1 Function rquired 引用
// (原 datatable.bundle.js require 會出問題,先以 cdn datatable.min.js引用)
require(["jquery"], loadedBasePack);
})
let url = baseApiUrl + "/api/Device/GetBaseDevice";
let sendData = {
device_guid: devGuid,
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
/**
* jquery.js 二次引用後 Callback載入第三方套件
* */
function loadedBasePack() {
require(
[
"lib/app.bundle",
"lib/app.menu",
"datatables.net.b4",
"n4js/alarmbaja",
"n4js/historybaja",
"lib/statistics/flot/flot.bundle",
"lib/statistics/peity/peity.bundle",
], loadedMasterPack);
}
/**
* 第三方套件引用後 Callback載入額外套件
* */
function loadedMasterPack() {
require(
[
"yourteam/yourteam.ajax.class",
"yourteam/yourteam.utility.class",
"yourteam/yourteam.jquery.datatables",
"yourteam/plugins/yt-tooltip/yt-tooltip",
"yourteam/plugins/yt-tab/yt-tab",
"style",
], function () {
require(["init", "site"], loadedJsPack)
});
}
/**
* 全數套件讀取完成 Callback
* */
function loadedJsPack() {
loadEvent();
if (!jwt) {
myBaja = new MyBaja();
myBaja.setMyUserAccount(Login);
} else {
tbody.find("tr").eq(0).append(creEle("td", res.data.device_number));
tbody.find("tr").eq(1).append(creEle("td", res.data.full_name));
isValidLogin();
}
}, null, "POST").send();
$(loadEle).Loading("close");
}
return tabEle.prop("outerHTML");
}
/**
* 登入驗證完成 Callback
* */
function isValidLogin() {
$("#app").load("_dashboard.html", loadCallback);
// Card - 異常紀錄 block
function drawErrRecTabBlo() {
let strHtml = `<table id="errRecTable" class="table table-bordered table-striped text-center m-0 w-100">
getBuiList();
getSysMonBtnList();
checkDevState();
function getSysMonBtnList() {
let url = baseApiUrl + "/api/Device/GetMainSub";
let sendData = {
building_tag: pageAct.buiTag,
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$("#sysMonBtnList").html()
$.each(res.data.history_Main_Systems, (index, mainSysObj) => {
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
let page = "systemMonitor";
if (subSysObj.sub_system_tag == "EL") {
page = "sysElevator";
}
let btn = creBtn(subSysObj.full_name, `subSysBtn${subSysObj.sub_system_tag}`, "topFunBtn", ["dropdown-item"], { page: page });
subSysObj.main_system_tag = mainSysObj.main_system_tag;
btn.data("subSysObj", subSysObj);
$("#sysMonBtnList").append(btn);
})
})
}
}, null, "POST").send();
}
function getBuiList() {
let url = baseApiUrl + "/api/Device/GetBuild";
ytAjax = new YourTeam.Ajax(url, null, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
let strHtml = ``;
$.each(res.data, (index, buiObj) => {
strHtml += `<a id="buiBtn${buiObj.building_tag}" class="dropdown-item" href="javascript:;">${buiObj.full_name}</a>`;
})
$("#buiList").append(strHtml).droSetItem(); //droSetItem 預設第一筆 active
}
}, null, "POST").send();
}
//lily test
function checkDevState() {
//TPE_B1_LT_L1
//main_system_tag: pageAct.sysMainTag,
//building_tag: pageAct.buiTag,
//floor_tag: pageAct.floTag,
let systemPath = "TPE_B1";
// if (pageAct != undefined && pageAct != null && pageAct.sysMainTag != null && pageAct.buiTag != null) {
// systemPath = "TPE_" + pageAct.buiTag + "_" + pageAct.sysMainTag + "_" + "EL";
// }
getOneSystemAlarmStateByBaja(systemPath, callbackForCheckDevState);
// console.log("systemP: " + systemPath);
// console.log("devList: " + deviceList[0].device_guid + ", " + deviceList[3].device_guid + ", " + deviceList[8].device_guid);
//callbackForCheckDevState("test");
}
function callbackForCheckDevState(result) {
console.log("------ " + result);
// $.each(deviceList, (index, devObj) => {
// if ((`${devObj.device_guid}`) == '4ed28a93-5025-11ed-b23e-0242ac110002'
// || (`${devObj.device_guid}`) == '5d9fdff0-5343-43fe-86f4-bd73cdb15111') {
// var str = "";
// $(`#${devObj.device_guid}`).empty();
// str = `<span class="status status-danger d-inline-block"><img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="..."></span> ${devObj.full_name}`;
// $(`#${devObj.device_guid}`).append(str);
// }
// })
console.log(result);
}
}
// page loaded callback
function loadCallback() {
initTabsByEle();
resetYTTooltip();
}
// 事件先行讀取
function loadEvent() {
onEvent("click", "[name=topFunBtn]", function () {
let needLoad = ["sysElevator", "historyData"];
_ytTabInited = [];
let page = $(this).data("page");
if (page != "systemMonitor") {
$("#sysMonBtnList .dropdown-item").removeClass("active");
pageAct.sysMainTag = null;
}
$.each(tolSubList, (idx, sub) => {
sub.unsubscribeAll();
sub.detach();
})
$("#app").load(`_${page}.html`, loadCallback);
// 需要 Loading 的頁面
if (needLoad.indexOf(page) != -1) {
$(loadEle).Loading("start", "資料讀取中...");
}
})
onEvent("click", "#logout", function () {
localStorage.removeItem("JWT-Authorization");
location.href = "/logout";
})
onEvent("active:change", "#sysMonBtnList", function (e, actEle) {
if (actEle) {
pageAct.sysMainTag = $(actEle).data("subSysObj").main_system_tag;
pageAct.sysSubTag = $(actEle).data("subSysObj").sub_system_tag;
pageAct.sysSubName = $(actEle).data("subSysObj").full_name;
pageAct.sysSubObj = $(actEle).data("subSysObj");
}
})
onEvent("active:change", "#buiList", function (e, actEle) {
if (actEle) {
pageAct.buiTag = $(actEle).prop("id").split("buiBtn")[1];
}
})
}
// 登入驗證
function Login(account) {
console.log(account)
/*if ($("#login-form").valid()) {*/
var url = baseApiUrl + "/api/Login/";
var send_data = {
account: account,
password: "rJ2T5Kkj"
}
if (location.href.indexOf("localhost:5966") != -1) {
location.href = "login.html";
}
$.ajax({
method: "post",
url: url,
data: JSON.stringify(send_data),
async: false,
contentType: "application/json; charset=UTF-8",
dataType: 'json',
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg || "系統內部發生錯誤,請聯絡系統管理員");
return;
}
else {
/*toast_ok(rel.msg);*/
localStorage.setItem('JWT-Authorization', rel.data.token);
isValidLogin();
}
},
error: function (xhr, textStatus, thrownError) {
alert(textStatus);
}
});
}
//==============================================================================
// ↓ 系統監控 - 共用 Function ↓
//==============================================================================
// Card - 基本資料 Table
function drawInfoTabBlo(devGuid) {
let tabEle = $(`<table class="table table-bordered table-striped text-center m-0">`);
let tbody = tabEle.append("<tbody>");
let columnNames = ["設備編號", "設備名稱"];
$.each(columnNames, (index, colName) => {
let tr = $("<tr></tr>");
let td = $("<td></td>");
td.text(colName);
tr.append(td);
tbody.append(tr);
})
let url = baseApiUrl + "/api/Device/GetBaseDevice";
let sendData = {
device_guid: devGuid,
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
tbody.find("tr").eq(0).append(creEle("td", res.data.device_number));
tbody.find("tr").eq(1).append(creEle("td", res.data.full_name));
}
}, null, "POST").send();
return tabEle.prop("outerHTML");
}
// Card - 異常紀錄 block
function drawErrRecTabBlo() {
let strHtml = `<table id="errRecTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>`
return strHtml;
}
return strHtml;
}
// Card - 運維紀錄 block
function drawOpeRecTabBlo() {
let strHtml = `<table id="opeRecTable" class="table table-bordered table-striped text-center m-0 w-100">
// Card - 運維紀錄 block
function drawOpeRecTabBlo() {
let strHtml = `<table id="opeRecTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>`
return strHtml;
}
return strHtml;
}
// Card 呈現初始化
function initPopover() {
$("[name=devItem]").each((index, ele) => {
let devNum = $(ele).data("number"); //設備編號
let devGuid = $(ele).data("id"); //guid
let devName = $(ele).data("name"); //full_name
$(ele).YTTooltip({
html: `<div class="card m-1 border device-wrap">
// Card 呈現初始化
function initPopover() {
$("[name=devItem]").each((index, ele) => {
let devNum = $(ele).data("number"); //設備編號
let devGuid = $(ele).data("id"); //guid
let devName = $(ele).data("name"); //full_name
$(ele).YTTooltip({
html: `<div class="card m-1 border device-wrap">
<div class="card-header p-3">
@ -2431,143 +2432,149 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
</div>
</div>`,
group: "device",
onShow: function (tooltipEle, oriEle) {
var tab = new YT.Tab({ tabName: "cardTab" })
loadOpeRecTable(devGuid);
//loadErrRecTable2($(oriEle).data("number"));
//loadErrRecTable();
loadErr($(oriEle).data("number"));
subDeviceSetTable ? subDeviceSetTable($(oriEle).data("number")) : ""
group: "device",
onShow: function (tooltipEle, oriEle) {
var tab = new YT.Tab({ tabName: "cardTab" })
loadOpeRecTable(devGuid);
//loadErrRecTable2($(oriEle).data("number"));
//loadErrRecTable();
loadErr($(oriEle).data("number"));
subDeviceSetTable ? subDeviceSetTable($(oriEle).data("number")) : ""
}
})
})
}
// Card - 運維紀錄 Table
function loadOpeRecTable(devGuid) {
let url = baseApiUrl + "/api/Device/GetOpeDevice?device_guid=" + devGuid;
let tag = "#opeRecTable";
let column_defs = [
{ "targets": [0], "width": "8%", "sortable": true },
{ "targets": [1], "width": "8%", "sortable": true },
{ "targets": [2], "width": "7%", "sortable": true },
{ "targets": [3], "width": "7%", "sortable": true },
];
let columns = [
{
"title": "類型",
"data": "work_type_name",
},
{
"title": "項目",
"data": "fix_do",
},
{
"title": "處理人員",
"data": "work_person_name",
},
{
"title": "發生/完成時間",
"data": "finishTime",
"render": function (data, type, row) {
return row.createdAt + "<br>" + data;
},
},
];
let opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "tpi");
}
// Baja 取得異常紀錄
function loadErr(allPath) {
if (allPath != undefined && allPath != null) {
let _pathArr = allPath.split("_");//TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
getOneDeviceAlarmTop10ByBaja(_devicePath, callbackForErr);
}
else {
console.log("no device");
}
}
// Card - 異常紀錄 Table
function callbackForErr(result) {
let tag = "#errRecTable";
let datas;
let column_defs = [
{ "targets": [0], "width": "15%", "sortable": true },
{ "targets": [1], "width": "25%", "sortable": true },
{ "targets": [2], "width": "25%", "sortable": true },
{ "targets": [3], "width": "35%", "sortable": true },
];
let columns = [
{
"title": "異常ID",
"data": "uuid",
},
{
"title": "異常原因",
"data": "msgText",
},
{
"title": "ACK確認",
"data": "ackState",
},
{
"title": "發生/完成時間",
"data": "normalTime",
"render": function (data, type, row) {
return row.timestamp + "<br>" + data;
},
},
];
let json_object = JSON.parse(result);
datas = json_object['data'];
errRecTable = new YourTeam.JqDataTables.getTableByStatic(tag, datas, columns, column_defs, null, null, null, null, "tpi");
}
//根據 data-type 設置顏色 (判斷後台是否有設定,若無則帶預設)
function setLightColor() {
$(".dev-card").each((index, ele) => {
let type = $(ele).find("[data-light-type]").data("light-type");
let isFlashing = false;
let color = "#000";
switch (type) {
case "normal":
color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
isFlashing = pageAct.sysSubObj.device_normal_flashing == "1";
break;
case "close":
color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
isFlashing = pageAct.sysSubObj.device_close_flashing == "1";
break;
case "error":
color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
isFlashing = pageAct.sysSubObj.device_error_flashing == "1";
break;
}
$(ele).find("[data-light-type]").css("background-color", color);
//是否閃爍
if (isFlashing) {
$(ele).addClass("light-flash");
}
})
})
}
// Card - 運維紀錄 Table
function loadOpeRecTable(devGuid) {
let url = baseApiUrl + "/api/Device/GetOpeDevice?device_guid=" + devGuid;
let tag = "#opeRecTable";
let column_defs = [
{ "targets": [0], "width": "8%", "sortable": true },
{ "targets": [1], "width": "8%", "sortable": true },
{ "targets": [2], "width": "7%", "sortable": true },
{ "targets": [3], "width": "7%", "sortable": true },
];
let columns = [
{
"title": "類型",
"data": "work_type_name",
},
{
"title": "項目",
"data": "fix_do",
},
{
"title": "處理人員",
"data": "work_person_name",
},
{
"title": "發生/完成時間",
"data": "finishTime",
"render": function (data, type, row) {
return row.createdAt + "<br>" + data;
},
},
];
let opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "tpi");
}
// Baja 取得異常紀錄
function loadErr(allPath) {
if (allPath != undefined && allPath != null) {
let _pathArr = allPath.split("_");//TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
getOneDeviceAlarmTop10ByBaja(_devicePath, callbackForErr);
}
else {
console.log("no device");
}
//==============================================================================
// ↑ 系統監控 - 共用 Function ↑
//==============================================================================
} catch(e) {
$(loadEle).Loading("close");
}
// Card - 異常紀錄 Table
function callbackForErr(result) {
let tag = "#errRecTable";
let datas;
let column_defs = [
{ "targets": [0], "width": "15%", "sortable": true },
{ "targets": [1], "width": "25%", "sortable": true },
{ "targets": [2], "width": "25%", "sortable": true },
{ "targets": [3], "width": "35%", "sortable": true },
];
let columns = [
{
"title": "異常ID",
"data": "uuid",
},
{
"title": "異常原因",
"data": "msgText",
},
{
"title": "ACK確認",
"data": "ackState",
},
{
"title": "發生/完成時間",
"data": "normalTime",
"render": function (data, type, row) {
return row.timestamp + "<br>" + data;
},
},
];
let json_object = JSON.parse(result);
datas = json_object['data'];
errRecTable = new YourTeam.JqDataTables.getTableByStatic(tag, datas, columns, column_defs, null, null, null, null, "tpi");
}
//根據 data-type 設置顏色 (判斷後台是否有設定,若無則帶預設)
function setLightColor() {
$(".dev-card").each((index, ele) => {
let type = $(ele).find("[data-light-type]").data("light-type");
let isFlashing = false;
let color = "#000";
switch (type) {
case "normal":
color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
isFlashing = pageAct.sysSubObj.device_normal_flashing == "1";
break;
case "close":
color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
isFlashing = pageAct.sysSubObj.device_close_flashing == "1";
break;
case "error":
color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
isFlashing = pageAct.sysSubObj.device_error_flashing == "1";
break;
}
$(ele).find("[data-light-type]").css("background-color", color);
//是否閃爍
if (isFlashing) {
$(ele).addClass("light-flash");
}
})
}
//==============================================================================
// ↑ 系統監控 - 共用 Function ↑
//==============================================================================
</script>
</body>

View File

@ -229,7 +229,7 @@ class elevator3D {
else if (movStatus == 1) {
fragProxy.position.z += this.speed;
}
this.fragProxys.filter(x => x.nodeId == nodeId && x.fragId == frag)[0].frag.position.z = fragProxy.position.z;
fragProxyZ = fragProxy.position.z;
fragProxy.updateAnimTransform()

View File

@ -42,8 +42,7 @@ function getElectricMeterTotalByBaja(devicePath, timeType, callback) {
* @param {any} callback
*/
function getElectricMeterNoweDataByBaja(devicePath, callback) {
var _result = "";
var _ss = "";
var _result = {count:0,data:[]};
var _index = 0;
require(['baja!'], function (baja) {//TPE/B1/EE/E4/R2F/NA/WHT/N1
@ -52,16 +51,15 @@ function getElectricMeterNoweDataByBaja(devicePath, callback) {
.then(function (table) {
return table.cursor({
each: function (record) {
if (_index == 0)
_ss += '{"name":"' + record.get('name') + '", "value":' + record.get('out').get('value') + '"}';
else
_ss += ',{"name":"' + record.get('name') + '", "value":' + record.get('out').get('value') + '"}';
let main = {}
main.name = record.get('name');
main.value = record.get('out').get('value');
_result.data.push(main);
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index + ', "data":[';
_result += _ss;
_result += ']}';
_result.count = _index;
if (typeof callback === 'function') {
callback(_result);
}
@ -289,9 +287,9 @@ function getElectricMeterDayDataByBaja(devicePath, company, startDateTime, endDa
return table.cursor({
each: function (record) {
if (_index == 0)
_ss += '{"timestamp":' + record.get('timestamp') + ', "endTimestamp":"' + record.get('endTimestamp') + ', "min":"' + record.get('min') + ', "max":"' + record.get('max') + ', "avg":"' + record.get('avg') + ', "sum":"' + record.get('sum') + '"}';
_ss += '{"timestamp":"' + record.get('timestamp') + '", "endTimestamp":"' + record.get('endTimestamp') + '", "min":"' + record.get('min') + '", "max":"' + record.get('max') + '", "avg":"' + record.get('avg') + '", "sum":"' + record.get('sum') + '"}';
else
_ss += ',{"timestamp":' + record.get('timestamp') + ', "endTimestamp":"' + record.get('endTimestamp') + ', "min":"' + record.get('min') + ', "max":"' + record.get('max') + ', "avg":"' + record.get('avg') + ', "sum":"' + record.get('sum') + '"}';
_ss += ',{"timestamp":"' + record.get('timestamp') + '", "endTimestamp":"' + record.get('endTimestamp') + '", "min":"' + record.get('min') + '", "max":"' + record.get('max') + '", "avg":"' + record.get('avg') + '", "sum":"' + record.get('sum') + '"}';
_index++;
},
after: function () {