From 22e68815a6d4c8aec22c5090da310bb676b8f378 Mon Sep 17 00:00:00 2001 From: dev01 Date: Sat, 3 Dec 2022 16:45:20 +0800 Subject: [PATCH] =?UTF-8?q?[Frontend][=E5=84=80=E9=8C=B6=E6=9D=BF]=20?= =?UTF-8?q?=E6=98=A8=E6=97=A5=E7=94=A8=E9=9B=BB=E9=87=8F=E3=80=81=E4=BB=8A?= =?UTF-8?q?=E6=97=A5=E7=94=A8=E9=9B=BB=E9=87=8F=E3=80=81=E5=8D=B3=E6=99=82?= =?UTF-8?q?=E5=8A=9F=E7=8E=87=20baja=20=E4=B8=B2=E6=8E=A5=20|=20[=E7=B3=BB?= =?UTF-8?q?=E7=B5=B1=E7=9B=A3=E6=8E=A7]=20=E9=9B=BB=E6=A2=AF=203D=20?= =?UTF-8?q?=E7=A7=BB=E5=8B=95=20=E7=AC=AC=E4=BA=8C=E6=AC=A1=E4=B9=8B?= =?UTF-8?q?=E5=BE=8C=E4=B8=8D=E5=8B=95=E5=95=8F=E9=A1=8C=E8=A7=A3=E6=B1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_dashboard.html | 69 ++- Frontend/_sysElevator.html | 12 +- Frontend/index.html | 831 +++++++++++++------------- Frontend/js/forge/forgemodel.js | 2 +- Frontend/js/n4js/electricmeterbaja.js | 20 +- Frontend/js/site.js | 2 +- 6 files changed, 479 insertions(+), 457 deletions(-) diff --git a/Frontend/_dashboard.html b/Frontend/_dashboard.html index 6f97a67..dbbc87f 100644 --- a/Frontend/_dashboard.html +++ b/Frontend/_dashboard.html @@ -9,7 +9,7 @@

- 560 + 今日用電量 kWH

@@ -20,7 +20,7 @@

- 6560 + 昨日用電量

@@ -69,7 +69,7 @@

- 9,218 + 即時功率

@@ -162,7 +162,7 @@
-
+
-
- 異常數量
18
- - 賦歸數量
28
+
+ 異常數量
18
+ + 賦歸數量
28
-
- 已確認異常
8
- - 未確認異常
6
+
+ 已確認異常
8
+ + 未確認異常
6
@@ -196,7 +196,7 @@
-
+
-
- 已完成
6
- - 未完成
8
+
+ 已完成
6
+ + 未完成
8
-
- 未派工
5
- - 派工中
9
+
+ 未派工
5
+ + 派工中
9
@@ -699,8 +699,8 @@ let strHtml = ``; $.each(res.data.history_Main_Systems, (index, mainSysObj) => { $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { - strHtml += `
- + strHtml += `
+
`; }) @@ -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); }) } diff --git a/Frontend/_sysElevator.html b/Frontend/_sysElevator.html index 47c96d5..f3e4410 100644 --- a/Frontend/_sysElevator.html +++ b/Frontend/_sysElevator.html @@ -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() diff --git a/Frontend/index.html b/Frontend/index.html index 7f6ab0b..b358b4e 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -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 += `${buiObj.full_name}`; - }) - $("#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 = `... ${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 = $(``); - let tbody = tabEle.append(""); - let columnNames = ["設備編號", "設備名稱"]; - - $.each(columnNames, (index, colName) => { - let tr = $(""); - let 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 = `
+ 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 += `${buiObj.full_name}`; + }) + $("#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 = `... ${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 = $(`
`); + let tbody = tabEle.append(""); + let columnNames = ["設備編號", "設備名稱"]; + + $.each(columnNames, (index, colName) => { + let tr = $(""); + let 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 = `
` - return strHtml; - } + return strHtml; + } - // Card - 運維紀錄 block - function drawOpeRecTabBlo() { - let strHtml = ` + // Card - 運維紀錄 block + function drawOpeRecTabBlo() { + let strHtml = `
` - 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: `
+ // 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: `
@@ -2431,143 +2432,149 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
`, - 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 + "
" + 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 + "
" + 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 + "
" + 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 + "
" + 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 ↑ - //============================================================================== + diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js index a88c444..b6726e8 100644 --- a/Frontend/js/forge/forgemodel.js +++ b/Frontend/js/forge/forgemodel.js @@ -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() diff --git a/Frontend/js/n4js/electricmeterbaja.js b/Frontend/js/n4js/electricmeterbaja.js index a3b12b7..910abc8 100644 --- a/Frontend/js/n4js/electricmeterbaja.js +++ b/Frontend/js/n4js/electricmeterbaja.js @@ -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 () { diff --git a/Frontend/js/site.js b/Frontend/js/site.js index 55248fa..4d5e78a 100644 --- a/Frontend/js/site.js +++ b/Frontend/js/site.js @@ -347,4 +347,4 @@ class ElevatorHandler { } } -} \ No newline at end of file +}