From bc1b2470ddad73d7dc56704d16c99e3002278a5e Mon Sep 17 00:00:00 2001 From: Celeste6666 Date: Sat, 11 Feb 2023 17:31:11 +0800 Subject: [PATCH] =?UTF-8?q?[frontedd]=20=E8=83=BD=E6=BA=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E8=87=AA=E5=8B=95=E9=A0=88=E9=87=8F=E5=9C=96?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20|=20=E6=AD=B7=E5=8F=B2=E8=B3=87=E6=96=99?= =?UTF-8?q?=E6=9F=A5=E8=A9=A2=E5=BE=8C=E6=AD=A3=E7=A2=BA=E5=91=88=E7=8F=BE?= =?UTF-8?q?=E8=B3=87=E6=96=99=20|=20=E9=A6=96=E9=A0=81=20icon=20=E8=AD=A6?= =?UTF-8?q?=E7=A4=BA=E5=BE=8C=E4=BF=AE=E6=94=B9=E7=82=BA=20gif=20|=20?= =?UTF-8?q?=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7=20=E4=BE=9B=E6=B0=B4?= =?UTF-8?q?=E7=B3=BB=E7=B5=B1=E5=8F=8A=E7=87=88=E5=85=B7=E5=91=88=E7=8F=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_dashboard.html | 93 ++-- Frontend/_energyManagement.html | 18 +- Frontend/_historyData.html | 821 ++++++++++++++++---------------- Frontend/_sysMonAll.html | 46 +- Frontend/js/n4js/historybaja.js | 132 ++--- 5 files changed, 577 insertions(+), 533 deletions(-) diff --git a/Frontend/_dashboard.html b/Frontend/_dashboard.html index 1f9a945..fb0460e 100644 --- a/Frontend/_dashboard.html +++ b/Frontend/_dashboard.html @@ -208,11 +208,7 @@ - - - \ No newline at end of file diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html index bdf581f..e30f7d3 100644 --- a/Frontend/_sysMonAll.html +++ b/Frontend/_sysMonAll.html @@ -376,13 +376,17 @@ function show3DModel(urn) { $(loadEle).Loading("start"); launchViewerForHotspot(urn, (viewer, nodeIds) => { - let devDbIds = allDevList.map(x => x.forge_dbid); - + let devDbIds = allDevList.map(x => x.forge_dbid); // 大類 + console.log(allDevList); + let subDevDbId = []; + allDevList.forEach(({ device_nodes }) => { + subDevDbId = [...subDevDbId, ...device_nodes.map(n => n.forge_dbid)] + }) // 從資料庫設定不可視模型的類型,若沒有取道該小類不可視類型,則套用資料庫設定預設類型 if (forgeInvType) { - setInviForge(forgeInvType, devDbIds); + setInviForge(forgeInvType, [...devDbIds, ...subDevDbId]); } else { - setInviForge(forgeInvTypeDef, devDbIds); + setInviForge(forgeInvTypeDef, [...devDbIds, ...subDevDbId]); } $(loadEle).Loading("close"); @@ -434,9 +438,11 @@ setForgeHotSpotColor(matchDevice); } } - } - + } + if (pageAct.sub_system_tag == "W2") { getWaterNodeId(); + } + }, () => { $(loadEle).Loading("close"); }, "[name=forgeViewer]"); @@ -444,20 +450,24 @@ // 供水系統 - 取得欲染色 dbid function getWaterNodeId() { - let url = baseApiUrl + "/api/Device/GetForgeNodeIdFromVar"; - let sendData = { forgeNodeKey: "water_wupply" }; - objSendData.Data = sendData; - ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { - if (!res || res.code != "0000" || !res.data) { + //let url = baseApiUrl + "/api/Device/GetForgeNodeIdFromVar"; + //let sendData = { forgeNodeKey: "water_wupply" }; + //objSendData.Data = sendData; + //ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { + // if (!res || res.code != "0000" || !res.data) { - } else { - if (!isNaN(parseInt(res.data[0]?.system_value))) { - changeColor(parseInt(res.data[0]?.system_value)) - } - console.log(res.data) - } - }, null, "POST").send(); + // } else { + // if (!isNaN(parseInt(res.data[0]?.system_value))) { + // changeColor(parseInt(res.data[0]?.system_value)) + // } + // console.log(res.data) + // } + //}, null, "POST").send(); + viewer.model.search("給水", (nodeIds) => { + console.log(nodeIds) + viewer.show(nodeIds) + }, (e) => { console.log(e) }) } function getHotspotPoint(callback = null) { diff --git a/Frontend/js/n4js/historybaja.js b/Frontend/js/n4js/historybaja.js index 5bf45a8..59c7c17 100644 --- a/Frontend/js/n4js/historybaja.js +++ b/Frontend/js/n4js/historybaja.js @@ -35,69 +35,83 @@ // } function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) { - var _result = ""; - var _ss = ""; - var _index = 0; + var _result = {}; + var _ss = []; + var _index = 0; - require(['baja!'], function (baja) { - console.log('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond); - baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get() - .then(function (table) { - return table.cursor({ - each: function (record) { - if (_index == 0) - _ss += '{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}'; - else - _ss += ',{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}'; - _index++; - }, - after: function () { - _result += '{' + '"count": ' + _index + ', "data":['; - _result += _ss; - _result += ']}'; - if (typeof callback === 'function') { - callback(_result); - } - }, - limit: -1, - offset: 0 - }); - }); - }); + require(['baja!'], function (baja) { + console.log('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond); + baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get() + .then(function (table) { + return table.cursor({ + each: function (record) { + console.log(record.get('timestamp')) + // if (_index == 0) + // _ss += '{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp').$cEncStr + // + '"}'; + // else + // _ss += ',{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp').$cEncStr + // + '"}'; + _ss.push({ + deviceName: deviceName, value: record.get('value'), timestamp: record.get('timestamp').$cEncStr + }); + _index++; + }, + after: function () { + _result = { count: _index, data: _ss } + // _result += '{' + '"count": ' + _index + ', "data":['; + // _result += _ss; + // _result += ']}'; + if (typeof callback === 'function') { + // console.log(_result) + _result = JSON.stringify(_result) + callback(_result); + } + }, + limit: -1, + offset: 0 + }); + }) + .catch(() => { + console.log("error"); + // const res = JSON.stringify({count:0, data:[]}) + callback() + }); + }); } function test3000p(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) { - var _result = ""; - var _ss = ""; - var _index = 0; - require(['baja!'], function (baja) { - "use strict"; - baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond) - .get( - function (table) { - - table.cursor({ - each: function (item) { - console.log("item: " + item); - if (_index == 0) - _ss += '{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}'; - else - _ss += ',{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}'; - _index++; - }, - after: function () { - _result += '{' + '"count": ' + _index + ', "data":['; - _result += _ss; - _result += ']}'; - if (typeof callback === 'function') { - callback(_result); - } - }, - limit: -1, - offset: 0 - }); - }) - }); + var _result = ""; + var _ss = ""; + var _index = 0; + require(['baja!'], function (baja) { + "use strict"; + baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond) + .get( + function (table) { + + table.cursor({ + each: function (item) { + console.log("item: " + item); + if (_index == 0) + _ss += '{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}'; + else + _ss += ',{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}'; + _index++; + }, + after: function () { + _result += '{' + '"count": ' + _index + ', "data":['; + _result += _ss; + _result += ']}'; + if (typeof callback === 'function') { + callback(_result); + } + }, + limit: -1, + offset: 0 + }); + }) + }); }