From 6ece49d36bc078153f928981137ca9d7183af88b Mon Sep 17 00:00:00 2001 From: dev01 Date: Sat, 7 Jan 2023 17:57:47 +0800 Subject: [PATCH] =?UTF-8?q?[Frontend]=20=E7=B4=80=E9=8C=84=E5=88=87?= =?UTF-8?q?=E6=8F=9B=E9=A0=81=E9=9D=A2=EF=BC=8C=E9=87=8D=E6=95=B4=E6=99=82?= =?UTF-8?q?=E6=81=A2=E5=BE=A9=E5=88=B0=E5=8E=9F=E6=9C=AC=E9=A0=81=E9=9D=A2?= =?UTF-8?q?=20|=20[=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7]=20=E7=B8=AE?= =?UTF-8?q?=E6=94=BE=20Card=20=E5=88=97=E8=A1=A8=E5=AF=AC=E9=AB=98?= =?UTF-8?q?=E8=87=AA=E9=81=A9=E6=87=89=20|=20[=E5=84=80=E9=8C=B6=E6=9D=BF]?= =?UTF-8?q?=20=E5=B7=A6=E4=B8=8B=E8=A7=92=E7=B3=BB=E7=B5=B1=E5=B0=8F?= =?UTF-8?q?=E9=A1=9E=20Card=20=E5=91=88=E7=8F=BE=E5=9B=9B=E8=A1=8C=20|=20?= =?UTF-8?q?=E5=B7=A5=E5=96=AE=E7=8B=80=E6=B3=81=E5=9C=93=E7=92=B0=E5=9C=96?= =?UTF-8?q?=E5=BB=BA=E7=BD=AE=20|=20[=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7]?= =?UTF-8?q?=20=E5=8D=A1=E7=89=87=E6=A0=B9=E6=93=9A=E5=BE=8C=E5=8F=B0?= =?UTF-8?q?=E8=A8=AD=E7=BD=AE=E9=95=B7=E5=AF=AC=20|=20[=E5=85=A8=E5=9F=9F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD]=20baja=20=E8=A8=82=E9=96=B1=E8=A8=AD?= =?UTF-8?q?=E5=82=99=20=E7=89=A9=E4=BB=B6=E5=8C=96=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=BB=BA=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_dashboard.html | 169 +++++++--- Frontend/_sysMonAll.html | 26 +- Frontend/_systemMonitor.html | 6 +- Frontend/css/site.css | 9 +- Frontend/index.html | 70 ++-- Frontend/js/forge/forgemodel.js | 1 + Frontend/js/n4js/bajatest.js | 547 ++++++++++++++++++++++---------- 7 files changed, 583 insertions(+), 245 deletions(-) diff --git a/Frontend/_dashboard.html b/Frontend/_dashboard.html index 473449a..5d5460b 100644 --- a/Frontend/_dashboard.html +++ b/Frontend/_dashboard.html @@ -161,27 +161,16 @@
-
+
-
+

異常狀態

-
-
- +
+
@@ -193,34 +182,20 @@
-
+

工單進度

-
-
- +
+
+
- 已完成
6
- - 未完成
8
+
- 未派工
5
- - 派工中
9
+
@@ -244,6 +219,8 @@ var timeOuters = []; var eveDayElecChart = null; var eveWeekElecChart = null; + var worOrdErrChart = null; + var worOrdFinChart = null; var errRecChart = null; var errChkChart = null; var loadedCnt = 0; @@ -262,6 +239,11 @@ { mainSys: "FE", subSys: "F2", iconClass: "fal fa-smog" }, { mainSys: "WP", subSys: "W1", iconClass: "fal fa-stopwatch" }, { mainSys: "S", subSys: "R", iconClass: "fal fa-user-shield" }, + { mainSys: "LT", subSys: "L2", iconClass: "fal fa-sun"}, + { mainSys: "ME", subSys: "M1", iconClass: "fal fa-icicles"}, + { mainSys: "ME", subSys: "M8", iconClass: "fal fa-bong"}, + { mainSys: "W3", subSys: "W1", iconClass: "fal fa-tint"}, + ]; var tempSysSubText = [ @@ -270,12 +252,16 @@ { text: "緊急發電機", mainSys: "EE", subSys: "E3", }, { text: "電錶系統", mainSys: "EE", subSys: "E4", }, { text: "二線式照明系統", mainSys: "LT", subSys: "L1", }, + { text: "景觀照明系統", mainSys: "LT", subSys: "L2", }, + { text: "儲冰系統", mainSys: "ME", subSys: "M1", }, { text: "小型送風機", mainSys: "ME", subSys: "M10", }, + { text: "排油煙設備", mainSys: "ME", subSys: "M8", }, { text: "環境感測設備", mainSys: "ME", subSys: "M12", }, { text: "電梯設備", mainSys: "ELEV", subSys: "EL", }, { text: "消防設備", mainSys: "FE", subSys: "F1", }, { text: "排煙系統", mainSys: "FE", subSys: "F2", }, { text: "電子水錶", mainSys: "WP", subSys: "W1", }, + { text: "熱水系統", mainSys: "W3", subSys: "W1", }, { text: "門禁安全系統", mainSys: "S", subSys: "R", } ]; @@ -291,7 +277,7 @@ let strHtml = ``; $.each(tempSysSubText, (idx, obj) => { - if (isExiNames.indexOf(obj.text) == -1 && $("#sysSubBtnList .dev-group").length < 12) { + if (isExiNames.indexOf(obj.text) == -1 && $("#sysSubBtnList .dev-group").length < 16) { let iconObj = sysIconList.filter(x => x.mainSys == obj.mainSys && x.subSys == obj.subSys)[0]; strHtml = `
@@ -408,14 +394,14 @@ // 本週與上週用電量 (每天) getElectricMeterDayDataByBaja(devNum + "_KWH", n4Sup, prevTwoWeek, tomorrow, (data) => { let curDay = (new Date()).getDay() == 0 ? 7 : (new Date()).getDay(); - let curWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr)); - let prevWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 0 - 7 - (curDay - 1)) <= strToDate(x.timestamp.$cEncStr) && strToDate(new Date(), null, 0 - 7) >= strToDate(x.timestamp.$cEncStr)); - + let curWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 1 - 7) <= strToDate(x.timestamp.$cEncStr)); + let prevWeekData = data.data.filter(x => strToDate(displayDate(new Date(), "date"), null, 1 - 14) <= strToDate(x.timestamp.$cEncStr) && strToDate(new Date(), null, 1 - 7) >= strToDate(x.timestamp.$cEncStr)); + debugger chartEveWeeksElec(curWeekData, prevWeekData) chkBajaLoaded(); }) - // 異常數量與賦歸數量 + // 異常數量與復歸數量 getAlarmCountByBaja((aData) => { chartDataCnt.alarmCnt = aData.count; chkBajaLoaded(); @@ -424,7 +410,7 @@ chartDataCnt.recCnt = rData.count; chkBajaLoaded(); }) - // 異常數量與賦歸數量 + // 異常數量與復歸數量 getCheckedAckedCountByBaja((data) => { chartDataCnt.chkedErrCnt = data.count; chkBajaLoaded(); @@ -440,8 +426,10 @@ loadedCnt++; if (loadedCnt == 9) { - chartErrRec(["異常數量", "賦歸數量"], [chartDataCnt.alarmCnt, chartDataCnt.recCnt]); + chartErrRec(["異常數量", "復歸數量"], [chartDataCnt.alarmCnt, chartDataCnt.recCnt]); chartErrChk(["已確認異常", "未確認異常"], [chartDataCnt.chkedErrCnt, chartDataCnt.unChkedErrCnt]); + chartWorOrdErr(); + chartWorOrdFin(); endPageLoading(); } @@ -628,7 +616,7 @@ } } - // 圖表 - 異常與賦歸圖表 (圓餅圖) + // 圖表 - 異常與復歸圖表 (圓餅圖) function chartErrRec(labels, datas) { let errRecChartCanvas = ctx = $('#errRecChart').get(0).getContext('2d'); @@ -720,6 +708,101 @@ } + // 圖表 - 異常未派工與異常已派工 (圓環圖) + function chartWorOrdErr(labels, datas) { + labels = ["異常未派工", "異常已派工"] + datas = [5, 9] + let worOrdErrChartCanvas = ctx = $('#worOrdErrChart').get(0).getContext('2d'); + + let worOrdErrChartData = { + labels: labels, + datasets: [ + { + label: '數量', + unit: '個', + fill: true, + backgroundColor: [color.danger._500, color.info._300], + //data: worOrdErrArr.map(x => parseInt((Math.random() * (1500 - 300) + 300))), + data: datas, + } + ] + } + + let worOrdErrChartOptions = { + //maintainAspectRatio: false, + responsive: true, + legend: { + display: true, + }, + tooltips: { + enabled: true, + }, + + + } + + if (worOrdErrChart == null) { + worOrdErrChart = new Chart(worOrdErrChartCanvas, { + type: "doughnut", + data: worOrdErrChartData, + options: worOrdErrChartOptions + }) + } else { + worOrdErrChart.data.datasets.forEach((dataset) => { + dataset.data = datas; + }); + } + + } + + // 圖表 - 工單已完成與工單未完成 (圓環圖) + function chartWorOrdFin(labels, datas) { + labels = ["工單已完成","工單未完成"] + datas = [5,9] + let worOrdFinChartCanvas = ctx = $('#worOrdFinChart').get(0).getContext('2d'); + + let worOrdFinChartData = { + labels: labels, + datasets: [ + { + label: '數量', + unit: '個', + fill: true, + backgroundColor: [color.danger._500, color.info._300], + //data: worOrdFinArr.map(x => parseInt((Math.random() * (1500 - 300) + 300))), + data: datas, + } + ] + } + + let worOrdFinChartOptions = { + //maintainAspectRatio: false, + responsive: true, + legend: { + display: true, + }, + tooltips: { + enabled: true, + }, + + + } + + if (worOrdFinChart == null) { + worOrdFinChart = new Chart(worOrdFinChartCanvas, { + type: "doughnut", + data: worOrdFinChartData, + options: worOrdFinChartOptions + }) + } else { + worOrdFinChart.data.datasets.forEach((dataset) => { + dataset.data = datas; + }); + } + + } + + // 從 baja 訂閱 左下角各系統小類異常狀態 function getAlarmSub(data) { $.each(data.data, (idx, alaObj) => { diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html index 5f05dd2..72defa2 100644 --- a/Frontend/_sysMonAll.html +++ b/Frontend/_sysMonAll.html @@ -38,11 +38,13 @@ var allDevList = []; //全設備清單 var subDeviceData = []; var heatMap = null; + var buildMenuData = {}; $(function () { getBuildMenu((arr, data) => { + buildMenuData = data; if (arr.indexOf(4) != -1) { - getFloDevList(); + getFloDevList(arr[0] == 4 ? "left" :"right"); setLightColor(); } if (arr.indexOf(3) != -1) { @@ -90,11 +92,11 @@ } myBaja.setSubscribeDevicesByBql(ordPath); myBaja.setSubscribeDevicesCallBack(function (data) { + let matchDevice = allDevList.filter(x => x.device_number == data.device_number_full)[0]; if (!matchDevice) { return false; } - //將訂閱值塞入 subDeviceData if (subDeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) { let obj = {}; @@ -127,9 +129,10 @@ } else if (data.point_name == errDevPoiName && data.value == matchDevice.device_error_point_value) { $(`#${matchDevice.device_number}_status`).attr("data-light-type", "error").data("light-type", "error"); } - + setLightColor(); setForgeHotSpotColor(matchDevice); + lightDevForgeSpotLig(matchDevice) // 從設備訂閱更新每個設備卡片即時點位 setDevItemPoiValBySub(data); }); @@ -139,6 +142,12 @@ }); } + function lightDevForgeSpotLig(devObj) { + + let position = isJSON(devObj.device_coordinate_3d) ? JSON.parse(devObj.device_coordinate_3d) : {}; + newLight(position); + } + // 從設備訂閱更新每個設備卡片即時點位 function setDevItemPoiValBySub(data) { @@ -220,7 +229,7 @@ } // 取得設備列表 並繪製卡片 - function getFloDevList() { + function getFloDevList(position = "left") { let url = baseApiUrl + "/api/Device/GetDeviceList"; let sendData = { sub_system_tag: pageAct.sysSubTag, @@ -240,7 +249,7 @@ $.each(floObj.device_list, (index2, devObj) => { allDevList.push(devObj); let devItem = getRiserPoiObj(); - strHtml += `
+ strHtml += `
@@ -314,8 +323,11 @@ // Card 即時狀態 function drawStateTabBlo(devNum) { let devPath = devNum.replaceAll("_", "/"); - let strHtml = `
- + let position = $(`.card.device-wrap[data-number=${devNum}]`).data("position"); + let width = buildMenuData[position + "_icon_click_url_width"] ? buildMenuData[position + "_icon_click_url_width"] + "px" : "100%"; + let height = buildMenuData[position + "_icon_click_url_height"] ? buildMenuData[position + "_icon_click_url_height"] + "px" : "100%"; + let strHtml = `
+
` return strHtml; } diff --git a/Frontend/_systemMonitor.html b/Frontend/_systemMonitor.html index 00e74ad..79ff8b6 100644 --- a/Frontend/_systemMonitor.html +++ b/Frontend/_systemMonitor.html @@ -1,8 +1,4 @@ - +
diff --git a/Frontend/css/site.css b/Frontend/css/site.css index c88262d..8258bc3 100644 --- a/Frontend/css/site.css +++ b/Frontend/css/site.css @@ -10,7 +10,7 @@ label[id$='-error'].error { color: var(--yt-red-2); } -[id^=yt_tooltip] { min-width: 650px !important; } +/*[id^=yt_tooltip] { min-width: 650px !important; }*/ .circle-light { display: inline-block; width: 25px; height: 25px; border-radius: 50px; } @@ -89,8 +89,11 @@ input:-webkit-autofill { background-color: rgba(0, 0, 0, 0.15) !important; } .yt-navbar-content ul li a:active, .yt-navbar-content ul li a.active { background-color: var(--theme-fusion-500); } .card-header.p-3.ui-draggable-handle:hover { cursor: move; } -@media screen and (max-width: 576px) { - .yt-left-navbar { width: 100%; max-width: 100%; margin-top: 0; } + +.device-wrap .card-body #info, .device-wrap .card-body #errRec, .device-wrap .card-body #opeRec { min-width: 500px; } +.scrolledTable { overflow-y: auto; clear: both; max-height:100%;} + +@media screen and (max-width: 576px) { .yt-left-navbar { width: 100%; max-width: 100%; margin-top: 0; } } @keyframes lds-ring { diff --git a/Frontend/index.html b/Frontend/index.html index e1ad296..b097139 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -726,9 +726,11 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li if (location.href.indexOf("ord") != -1) { location.href = "/file/index.html" } + var lastPage = sessionStorage.getItem("lastPage"); // 執行初步 Loading var loadEle = pageLoading(); var errRecTable = null, opeRecTable = null; + var tolSubList = []; /** * 頁面 Loading 建立 @@ -825,8 +827,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li * 登入驗證完成 Callback * */ function isValidLogin() { - $("#app").load("_dashboard.html", loadCallback); - + getUserInfo(); iniFroList(); showMainSys(); @@ -834,6 +835,23 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li getSysMonBtnList(); checkDevState(); + if (lastPage) { + let lastPageAct = {}; + if (isJSON(sessionStorage.getItem("pageAct"))) { + lastPageAct = JSON.parse(sessionStorage.getItem("pageAct")); + } + if (lastPageAct.sysSubTag) { + $(`#subSysBtn${lastPageAct.sysSubTag}`).click(); + } else { + $(`[name=topFunBtn][data-page=${lastPage}]`).click(); + } + + /*$(`[name=topFunBtn][data-page=${lastPage}]`).click();*/ + } else { + $("#app").load("_dashboard.html", loadCallback); + } + + function getBuiList() { let url = baseApiUrl + "/api/Device/GetBuild"; ytAjax = new YourTeam.Ajax(url, null, function (res) { @@ -897,6 +915,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li if (page != "systemMonitor") { $("#sysMonBtnList .dropdown-item").removeClass("active"); pageAct.sysMainTag = null; + } else { + setSysTagForPageAct(this); } $.each(tolSubList, (idx, sub) => { sub.unsubscribeAll(); @@ -914,6 +934,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li } getUserInfo(); + sessionStorage.setItem("lastPage", page); + sessionStorage.setItem("pageAct", JSON.stringify(pageAct)); $("#app").load(`_${page}.html`, loadCallback); }) @@ -923,13 +945,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li location.href = "/logout"; }) - onEvent("click", "#sysMonBtnList a", function (e) { - pageAct.sysMainTag = $(this).data("subSysObj").main_system_tag; - pageAct.sysSubTag = $(this).data("subSysObj").sub_system_tag; - pageAct.sysSubName = $(this).data("subSysObj").full_name; - pageAct.sysSubObj = $(this).data("subSysObj"); - getDevItem(); - }) onEvent("active:change", "#buiList", function (e, actEle) { if (actEle) { @@ -1081,7 +1096,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
-
+
${drawStateTabBlo(devNum)}
@@ -1107,18 +1122,27 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li } $(tooltipEle).draggable({ cursor: "move", - handle: ".card-header" // 只能通过卡片的标题栏拖拽 + handle: ".card-header", // 只能通过卡片的标题栏拖拽 + containment: "document", + scroll: true }); $(tooltipEle).resizable({ resize: function (event,ui) { let iframe = $(ui.element).find("iframe"); if (iframe.length != 0) { - //let cardBodyHei = $(ui.element).find(".card-body").css("height"); - //if (cardBodyHei) { - // $(iframe).css("height", cardBodyHei); - //} + if (ui.size.width != ui.originalSize.width) { + iframe.css("width", "100%"); + } else if (ui.size.height != ui.originalSize.height) { + iframe.css("height", "100%"); + } } - } + let cardBodyHeight = $(ui.element).find(".card-body").css("height"); + $(ui.element).find(".scrolledTable").css("height", cardBodyHeight) + + errRecTable.draw(false) + }, + minWidth: 200, + minHeight:150, }); typeof subDeviceSetTable != "undefined" ? subDeviceSetTable($(oriEle).data("number")) : "" }, @@ -1173,7 +1197,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li ]; - opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "tpi"); + opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "<'scrolledTable'tpi>"); } function loadLightSchTable(devGuid) { @@ -1295,7 +1319,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li 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"); + errRecTable = new YourTeam.JqDataTables.getTableByStatic(tag, datas, columns, column_defs, null, null, null, null, "<'scrolledTable'tpi>"); } @@ -1351,6 +1375,14 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li $(loadEle).Loading("close"); } + function setSysTagForPageAct(obj) { + pageAct.sysMainTag = $(obj).data("subSysObj").main_system_tag; + pageAct.sysSubTag = $(obj).data("subSysObj").sub_system_tag; + pageAct.sysSubName = $(obj).data("subSysObj").full_name; + pageAct.sysSubObj = $(obj).data("subSysObj"); + getDevItem(); + } + function getDevItem() { let url = baseApiUrl + "/api/Device/GetDeviceItem"; @@ -1481,7 +1513,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li } else { $("#sysMonBtnList").html("") - debugger + $.each(res.data.history_Main_Systems, (index, mainSysObj) => { $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { let page = "systemMonitor"; diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js index ceff637..a021bc5 100644 --- a/Frontend/js/forge/forgemodel.js +++ b/Frontend/js/forge/forgemodel.js @@ -1106,6 +1106,7 @@ async function newLight(lightPosition) { //聚光燈 var spotLight = new THREE.SpotLight(0xffffff, 200, 20, 0.6, 0.5, 10); spotLight.position.set(lightPosition.x, lightPosition.y, lightPosition.z); + console.log(lightPosition.x, lightPosition.y, lightPosition.z) spotLight.castShadow = false; spotLight.visible = true; spotLight.target.position.set(lightPosition.x, lightPosition.y, lightPosition.z-20); diff --git a/Frontend/js/n4js/bajatest.js b/Frontend/js/n4js/bajatest.js index 48a98b9..29849a5 100644 --- a/Frontend/js/n4js/bajatest.js +++ b/Frontend/js/n4js/bajatest.js @@ -21,27 +21,238 @@ var endPageLoading; // 開始 loading window.tolSubList = []; var user_name = ""; -function subscriptionDevices() { - // 用BQL的方式去訂閱 - this.setSubscribeDevicesByBql = function (tempOrdPath) { - ordPath = tempOrdPath; - BajaSubscribeDevicesByBql(); + +class subscriptionDevices { + constructor() { + this.ordPath = {}; + this.changeCallback = null; + this.changeEndCallback = null; + } + + setSubscribeDevicesByBql = function (tempOrdPath) { + this.ordPath = tempOrdPath; + this.BajaSubscribeDevicesByBql(); }; - // BQL去訂閱回傳的Function - this.setSubscribeDevicesCallBack = function (callBackFunc) { + + setSubscribeDevicesCallBack = function (callBackFunc) { if (callBackFunc != undefined && callBackFunc != null) { - baja_subscribe_device_callback_func = callBackFunc; + this.changeCallback = callBackFunc; } } // BQL訂閱結束回傳的Function - this.setSubscribeDeviceEndCallBack = function (callBackFunc) { + setSubscribeDeviceEndCallBack = function (callBackFunc) { if (callBackFunc != undefined && callBackFunc != null) { - baja_subscribe_end_device_callback_func = callBackFunc; + this.changeEndCallback = callBackFunc; } } + BajaSubscribeDevicesByBql = function () { + let _this = this; + 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 (_this.changeCallback != undefined && _this.changeCallback != null) { + _this.changeCallback(modify_target_device, true); //第2參數用在平面圖,刷新畫面 + } + } + }, function (err) { + console.log(err) + }); + + //使用bql語法 + // var building_tag = "H"; + // var system_tag = "M10"; + // baja.Ord.make(`ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/${building_tag}/${system_tag}|bql:select name, displayname, slotPath, out.value, out from control:ControlPoint`) + console.log(`local:|foxs:|station:|slot:/TPE/${_this.ordPath.building_tag}/${_this.ordPath.system_tag}/${_this.ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, facets from control:ControlPoint`); + baja.Ord.make(`local:|foxs:|station:|slot:/TPE/${_this.ordPath.building_tag}/${_this.ordPath.system_tag}/${_this.ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, 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()); + // $("#readPath-finish-timestamp").html(readBqlFinish.toISOString()); + // $("#readPath-finish-time").html((readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec"); + 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()); + + + }, + 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 (_this.changeCallback != undefined && _this.changeCallback != null) { + _this.changeCallback(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(); + + // //依據Facets判斷回傳的內容值為何 + // var facets_split = component.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 = component.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, + // "point_name": point_name ? point_name : null, + // "value": key + // } + + // //取得component當下就更新設備點位 + // if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { + // if (component_index == total_component_index) { + // baja_subscribe_device_callback_func(modify_target_device, true); + // } + // else { + // baja_subscribe_device_callback_func(modify_target_device); + // } + // } + + 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()); + // $("#table-finish-timestamp").html(tableFinish.toISOString()); + // $("#table-time").html((tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); + //取得component當下就更新設備點位 + if (_this.changeEndCallback != undefined && _this.changeEndCallback != null) { + _this.changeEndCallback(totalTargetDevice); + } + endPageLoading ? endPageLoading() : "" + console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); + }, + limit: -1, + offset: 0 + }); + }); + }) + } } +//function subscriptionDevices() { +// // 用BQL的方式去訂閱 +// this.setSubscribeDevicesByBql = function (tempOrdPath) { +// ordPath = tempOrdPath; +// BajaSubscribeDevicesByBql(); +// }; +// // BQL去訂閱回傳的Function +// this.setSubscribeDevicesCallBack = function (callBackFunc) { +// if (callBackFunc != undefined && callBackFunc != null) { +// baja_subscribe_device_callback_func = callBackFunc; +// } +// } +// // BQL訂閱結束回傳的Function +// this.setSubscribeDeviceEndCallBack = function (callBackFunc) { +// if (callBackFunc != undefined && callBackFunc != null) { +// baja_subscribe_end_device_callback_func = callBackFunc; +// } +// } + +//} + function subscriptionAlarms() { // 用BQL的方式去訂閱 this.setSubscribeAlarmsByBql = function (tempOrdPath) { @@ -96,191 +307,191 @@ function MyBaja() { /** * 使用者透過BQL指定路徑去訂閱設備點位 */ -function BajaSubscribeDevicesByBql() { +//function BajaSubscribeDevicesByBql() { - require(['baja!'], function (baja) { - console.log("進入Function 準備執行BQL訂閱"); - startPageLoading ? startPageLoading() : "" - var init_start = new Date(Date.now()); - var sub = new baja.Subscriber(); +// 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(); +// 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:')); - }); +// //依據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 facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {}) - var point_out_split = this.getOutDisplay().split(' '); +// var point_out_split = this.getOutDisplay().split(' '); - let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]); +// let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]); - if (key == undefined) { - key = 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 - } +// 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_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { - baja_subscribe_device_callback_func(modify_target_device, true); //第2參數用在平面圖,刷新畫面 - } - } - }, function (err) { - console.log(err) - }); +// if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { +// baja_subscribe_device_callback_func(modify_target_device, true); //第2參數用在平面圖,刷新畫面 +// } +// } +// }, function (err) { +// console.log(err) +// }); - //使用bql語法 - // var building_tag = "H"; - // var system_tag = "M10"; - // baja.Ord.make(`ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/${building_tag}/${system_tag}|bql:select name, displayname, slotPath, out.value, out from control:ControlPoint`) - console.log(`local:|foxs:|station:|slot:/${ordPath.area_tag}/${ordPath.building_tag}/${ordPath.system_tag}/${ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, facets from control:ControlPoint`); - baja.Ord.make(`local:|foxs:|station:|slot:/${ordPath.area_tag}/${ordPath.building_tag}/${ordPath.system_tag}/${ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, 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()); - // $("#readPath-finish-timestamp").html(readBqlFinish.toISOString()); - // $("#readPath-finish-time").html((readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec"); - 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()); +// //使用bql語法 +// // var building_tag = "H"; +// // var system_tag = "M10"; +// // baja.Ord.make(`ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/${building_tag}/${system_tag}|bql:select name, displayname, slotPath, out.value, out from control:ControlPoint`) +// console.log(`local:|foxs:|station:|slot:/TPE/${ordPath.building_tag}/${ordPath.system_tag}/${ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, facets from control:ControlPoint`); +// baja.Ord.make(`local:|foxs:|station:|slot:/TPE/${ordPath.building_tag}/${ordPath.system_tag}/${ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, 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()); +// // $("#readPath-finish-timestamp").html(readBqlFinish.toISOString()); +// // $("#readPath-finish-time").html((readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec"); +// 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; +// }, +// 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"); +// 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判斷回傳的內容值為何 +// 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] }), {}) +// facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {}) - var point_out_split = this.getDisplay("out").split(' '); +// var point_out_split = this.getDisplay("out").split(' '); - let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]); +// let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]); - if (key == undefined) { - key = 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_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { - baja_subscribe_device_callback_func(modify_target_device); - } +// 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_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { +// baja_subscribe_device_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(); +// 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(); - // //依據Facets判斷回傳的內容值為何 - // var facets_split = component.getFacets1().$cEncStr.split('|'); - // var facets_arr = []; - // facets_split.forEach(function (item, index) { - // facets_arr.push(item.split('=s:')); - // }); +// // //依據Facets判斷回傳的內容值為何 +// // var facets_split = component.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 facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {}) - // var point_out_split = component.getOutDisplay().split(' '); +// // var point_out_split = component.getOutDisplay().split(' '); - // let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]); +// // let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]); - // if (key == undefined) { - // key = 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, - // "point_name": point_name ? point_name : null, - // "value": key - // } +// // var modify_target_device = { +// // "device_number": target_device_number ? target_device_number : null, +// // "point_name": point_name ? point_name : null, +// // "value": key +// // } - // //取得component當下就更新設備點位 - // if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { - // if (component_index == total_component_index) { - // baja_subscribe_device_callback_func(modify_target_device, true); - // } - // else { - // baja_subscribe_device_callback_func(modify_target_device); - // } - // } +// // //取得component當下就更新設備點位 +// // if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) { +// // if (component_index == total_component_index) { +// // baja_subscribe_device_callback_func(modify_target_device, true); +// // } +// // else { +// // baja_subscribe_device_callback_func(modify_target_device); +// // } +// // } - 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()); - // $("#table-finish-timestamp").html(tableFinish.toISOString()); - // $("#table-time").html((tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); - //取得component當下就更新設備點位 - if (baja_subscribe_end_device_callback_func != undefined && baja_subscribe_end_device_callback_func != null) { - baja_subscribe_end_device_callback_func(totalTargetDevice); - } - endPageLoading ? endPageLoading() : "" - console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); - }, - limit: -1, - offset: 0 - }); - }); - }) -} +// 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()); +// // $("#table-finish-timestamp").html(tableFinish.toISOString()); +// // $("#table-time").html((tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); +// //取得component當下就更新設備點位 +// if (baja_subscribe_end_device_callback_func != undefined && baja_subscribe_end_device_callback_func != null) { +// baja_subscribe_end_device_callback_func(totalTargetDevice); +// } +// endPageLoading ? endPageLoading() : "" +// console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec"); +// }, +// limit: -1, +// offset: 0 +// }); +// }); +// }) +//} /** * 使用者透過BQL指定路徑去訂閱Alarm @@ -296,7 +507,7 @@ function BajaSubscribeAlarmsByBql(ordPathForAlarm) { var sourceState = (this.$map.$map.in10.$val.$map.$map.value.$display) == 'true' ? "Offnormal" : "Normal"; var modify_target_device = { - "system": ordPathForAlarm.area_tag + "_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag, + "system": "TPE_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag, "sourceState": sourceState ? sourceState : null } @@ -307,8 +518,8 @@ function BajaSubscribeAlarmsByBql(ordPathForAlarm) { }); //使用bql語法 - console.log(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, normalTime where alarmData.sourceName like '%${ordPathForAlarm.area_tag}_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`); - baja.Ord.make(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, alarmData, alarmData.sourceName, normalTime where alarmData.sourceName like '%${ordPathForAlarm.area_tag}_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`) + console.log(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, normalTime where alarmData.sourceName like '%TPE_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`); + baja.Ord.make(`local:|foxs:|alarm:|bql:select top 1 timestamp, sourceState, alarmData, alarmData.sourceName, normalTime where alarmData.sourceName like '%TPE_${ordPathForAlarm.building_tag}_${ordPathForAlarm.system_tag}_${ordPathForAlarm.name_tag}_%' order by timestamp desc`) .get( function (table) { var tableStart, tableFinish; @@ -338,7 +549,7 @@ function BajaSubscribeAlarmsByBql(ordPathForAlarm) { var normalTime = this.getDisplay("normalTime"); var modify_target_device = { - "system": ordPathForAlarm.area_tag + "_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag, + "system": "TPE_" + ordPathForAlarm.building_tag + "_" + ordPathForAlarm.system_tag + "_" + ordPathForAlarm.name_tag, "sourceState": sourceState ? sourceState : null } totalTargetDevice.push(modify_target_device);