From 17c472be33dfd9a443e2dc34fe41b9582e470959 Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 6 Jan 2023 18:39:55 +0800 Subject: [PATCH 01/12] =?UTF-8?q?[FrontendWebApi]=20=E5=8F=96=E5=BE=97=20D?= =?UTF-8?q?evice=20Item=20=E7=B3=BB=E7=B5=B1=E5=B0=8F=E9=A1=9E=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E9=BB=9E=E4=BD=8D=E8=B3=87=E8=A8=8A=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=BB=BA=E7=BD=AE=20|=20[Frontend]=20=E7=B3=BB=E7=B5=B1?= =?UTF-8?q?=E7=9B=A3=E6=8E=A7=E8=A8=AD=E5=82=99=E5=8D=A1=E7=89=87=E9=BB=9E?= =?UTF-8?q?=E4=BD=8D=E5=80=BC=E5=91=88=E7=8F=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_sysMonAll.html | 29 +++++++++++--- Frontend/index.html | 17 +++++++++ .../ApiControllers/DeviceManageController.cs | 38 +++++++++++++++++++ FrontendWebApi/Models/Device.cs | 23 +++++++++++ 4 files changed, 102 insertions(+), 5 deletions(-) diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html index 4bab82c..5f05dd2 100644 --- a/Frontend/_sysMonAll.html +++ b/Frontend/_sysMonAll.html @@ -94,7 +94,7 @@ if (!matchDevice) { return false; } - console.log(data) + //將訂閱值塞入 subDeviceData if (subDeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) { let obj = {}; @@ -130,14 +130,24 @@ setLightColor(); setForgeHotSpotColor(matchDevice); + // 從設備訂閱更新每個設備卡片即時點位 + setDevItemPoiValBySub(data); }); myBaja.setSubscribeDeviceEndCallBack(function (data) { - endPageLoading(); }); } + // 從設備訂閱更新每個設備卡片即時點位 + function setDevItemPoiValBySub(data) { + + let pointSpan = $(`.card.device-wrap[data-number=${data.device_number_full}] span[name=devItemPoiVal]`); + if (pointSpan && pointSpan.data("point") == data.point_name) { + console.log(data) + pointSpan.text(data.value); + } + } function setLightColor() { $("[data-light-type]").each((index, ele) => { @@ -200,6 +210,15 @@ } } + // 取得昇位圖點位 (deviceItem) + function getRiserPoiObj() { + let tarDevItem = pageAct.devItems?.filter(x => x.is_show_riserDiagram == 1); + if (tarDevItem && tarDevItem[0]) { + return tarDevItem[0]; + } + return null; + } + // 取得設備列表 並繪製卡片 function getFloDevList() { let url = baseApiUrl + "/api/Device/GetDeviceList"; @@ -220,8 +239,8 @@ strHtml += `
` $.each(floObj.device_list, (index2, devObj) => { allDevList.push(devObj); - - strHtml += `
+ let devItem = getRiserPoiObj(); + strHtml += `
@@ -233,7 +252,7 @@
- 即時功率: + ${devItem?.full_name}:${devItem?.unit} 詳細資料
diff --git a/Frontend/index.html b/Frontend/index.html index 95f51a5..e1ad296 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -928,6 +928,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li 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) { @@ -1350,6 +1351,22 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li $(loadEle).Loading("close"); } + function getDevItem() { + let url = baseApiUrl + "/api/Device/GetDeviceItem"; + + objSendData.Data = { + main_system_tag: pageAct.sysMainTag, + sub_system_tag: pageAct.sysSubTag, + } + ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { + if (!res || res.code != "0000" || !res.data) { + + } else { + pageAct.devItems = res.data; + } + }, null, "POST").send(); + } + function alarmIconBlink(data) { if (data?.data.length != 0) { $(".page-header [name=topFunBtn][data-page=alert] i").addClass("blink"); diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 9278553..1f0e2eb 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -872,5 +872,43 @@ namespace FrontendWebApi.ApiControllers } return Ok(apiResult); } + + /// + /// 取得 Device Item 系統小類下的點位資訊 + /// + /// + /// + [HttpPost] + [Route("api/Device/GetDeviceItem")] + public async Task>>> GetDeviceItem([FromBody] FindDeviceItem fdi) + { + ApiResult> apiResult = new ApiResult>(); + + if (string.IsNullOrEmpty(fdi.main_system_tag) || string.IsNullOrEmpty(fdi.sub_system_tag)) + { + apiResult.Code = "0002"; + apiResult.Msg = "需傳入大小類tag"; + return apiResult; + } + + try + { + var sqlString = $@" SELECT * FROM device_item + WHERE deleted = '0' AND device_system_tag = @main_system_tag AND device_name_tag = @sub_system_tag AND points = IFNULL(@points,points)"; + var param = new { @main_system_tag = fdi.main_system_tag, @sub_system_tag = fdi.sub_system_tag, @points = fdi.points }; + var fr = await backendRepository.GetAllAsync(sqlString, param); + + apiResult.Code = "0000"; + apiResult.Data = fr; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } } } \ No newline at end of file diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index c8db861..0508d4e 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -141,4 +141,27 @@ namespace FrontendWebApi.Models public string device_node_coordinate_3d { get; set; } public int? forge_dbid { get; set; } } + + public class DeviceItemViewModel + { + public int id { get; set; } + public short deleted { get; set; } + public string full_name { get; set; } + public string points { get; set; } + public string unit { get; set; } + public short is_show { get; set; } + public short? is_show_riserDiagram { get; set; } + public short is_controll { get; set; } + public short is_bool { get; set; } + public short is_link { get; set; } + public short is_show_history { get; set; } + public string device_system_tag { get; set; } + public string device_name_tag { get; set; } + } + + public class FindDeviceItem : FindDevice + { + public string points { get; set; } + + } } From 29ff2a2919bdf9db0921a12a37d04683626b9eb7 Mon Sep 17 00:00:00 2001 From: dev01 Date: Sat, 7 Jan 2023 12:16:54 +0800 Subject: [PATCH 02/12] =?UTF-8?q?[Backend][=E5=8D=80=E5=9F=9F=E9=81=B8?= =?UTF-8?q?=E5=96=AE=E8=A8=AD=E5=AE=9A]=20=E9=81=B8=E5=96=AE=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E9=A1=AF=E7=A4=BA=E8=A9=B3=E7=B4=B0=E8=B3=87=E6=96=99?= =?UTF-8?q?=E5=8F=AA=E6=94=B9=E5=8F=96=E6=8A=938=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=8F=A6=E5=A4=96=E8=A8=AD=E5=AE=9Aurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Views/BuildMenu/Index.cshtml | 46 +++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/Backend/Views/BuildMenu/Index.cshtml b/Backend/Views/BuildMenu/Index.cshtml index b780a8f..c8ff911 100644 --- a/Backend/Views/BuildMenu/Index.cshtml +++ b/Backend/Views/BuildMenu/Index.cshtml @@ -54,11 +54,9 @@ 左邊預設頁面 左邊是否顯示
平面圖 左邊昇位圖
詳細資料設定 - 左邊昇位圖
詳細資料URL 右邊預設頁面 右邊是否顯示
平面圖 右邊昇位圖
詳細資料設定 - 右邊昇位圖
詳細資料URL @*昇位圖URL*@ 功能 @@ -215,12 +213,12 @@
- +
-
+ @*

@@ -229,7 +227,7 @@ -
+
*@

@@ -340,12 +338,12 @@
- +
-
+ @*

@@ -354,7 +352,7 @@ -
+
*@

@@ -478,14 +476,14 @@ str.push("點擊開關") } if (1 & parseInt(data) > 0) { - str.push("顯示詳細資料") + str.push("顯示詳細資料 - (抓取設備八段路徑呈現詳細資料)") } return str.join(";"); } }, - { - "data": "left_icon_click_url" - }, + //{ + // "data": "left_icon_click_url" + //}, { "data": "right_drawing_name" }, @@ -500,14 +498,14 @@ str.push("點擊開關") } if (1 & parseInt(data) > 0) { - str.push("顯示詳細資料") + str.push("顯示詳細資料 - (抓取設備八段路徑呈現詳細資料)") } return str.join(";"); } }, - { - "data": "right_icon_click_url" - }, + //{ + // "data": "right_icon_click_url" + //}, { "data": null, "render": function (data, type, row, meta){ @@ -542,13 +540,13 @@ $.each(this.data, function (k, rel) { rel.sub_system_guid_name = "" + rel.sub_system_guid_name + "" if (rel.left_drawing == 2) { - rel.left_drawing_name = rel.left_drawing_name + "
" + '點擊連結' + rel.left_drawing_name = rel.left_drawing_name + "
" + '點擊連結' } if (rel.left_drawing == 1) { rel.left_drawing_name = rel.left_drawing_name + "
" + '[' + rel.floor_guid_name + ']' } if (rel.right_drawing == 2) { - rel.right_drawing_name = rel.right_drawing_name + "
" + '點擊連結' + rel.right_drawing_name = rel.right_drawing_name + "
" + '點擊連結' } if (rel.right_drawing == 1) { rel.right_drawing_name = rel.right_drawing_name + "
" + '[' + rel.floor_guid_name + ']' @@ -787,20 +785,20 @@ //#endregion $('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () { if ($(this).prop("checked") && $(this).val() == 1) { - $('#build_menu_icon_click_url_modal_div').show(); + //$('#build_menu_icon_click_url_modal_div').show(); $('#build_menu_icon_click_url_width_height_modal_div').show(); } else { - $('#build_menu_icon_click_url_modal_div').hide(); + //$('#build_menu_icon_click_url_modal_div').hide(); $('#build_menu_icon_click_url_width_height_modal_div').hide(); } }); $('#build_menu_icon_click_onoff_modal_div_r').on("click", "input[type=checkbox]", function () { if ($(this).prop("checked") && $(this).val() == 1) { - $('#build_menu_icon_click_url_modal_div_r').show(); + //$('#build_menu_icon_click_url_modal_div_r').show(); $('#build_menu_icon_click_url_width_height_modal_div_r').show(); } else { - $('#build_menu_icon_click_url_modal_div_r').hide(); + //$('#build_menu_icon_click_url_modal_div_r').hide(); $('#build_menu_icon_click_url_width_height_modal_div_r').hide(); } }); @@ -977,7 +975,7 @@ let drawingParent = $(value).parents("[id^=build_menu_position]") $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').hide(); - $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide(); + //$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide(); @@ -989,7 +987,7 @@ $(drawingParent).find('[id^="planimetric_click"]').attr("disabled", false); $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show(); if ($(drawingParent).find("[id^=icon_click_url]").prop('checked')) { - $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show(); + //$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show(); $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show(); } } else if ($(value).val() == 1) { From 6ece49d36bc078153f928981137ca9d7183af88b Mon Sep 17 00:00:00 2001 From: dev01 Date: Sat, 7 Jan 2023 17:57:47 +0800 Subject: [PATCH 03/12] =?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); From 4b89b14fac8160f43305c1a438dfc65226000854 Mon Sep 17 00:00:00 2001 From: wanli Date: Sat, 7 Jan 2023 22:17:08 +0800 Subject: [PATCH 04/12] =?UTF-8?q?[Backend]=20=E5=8F=96=E5=BE=97=E6=88=BF?= =?UTF-8?q?=E9=96=93=E8=B3=87=E8=A8=8A=20=EF=BC=8C=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=87=B3forge=5Froom=E8=B3=87=E6=96=99=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/DeviceImportController.cs | 89 +++++- Backend/Models/Device.cs | 19 ++ Backend/wwwroot/forgeDemo.html | 39 ++- Backend/wwwroot/js/forge/ForgeDemo.js | 293 ++---------------- 4 files changed, 167 insertions(+), 273 deletions(-) diff --git a/Backend/Controllers/DeviceImportController.cs b/Backend/Controllers/DeviceImportController.cs index 7b03b95..0a873a8 100644 --- a/Backend/Controllers/DeviceImportController.cs +++ b/Backend/Controllers/DeviceImportController.cs @@ -800,9 +800,6 @@ namespace Backend.Controllers device.Add("@forge_dbid", idfc.forge_dbid); await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'"); } - - - } } apiResult.Code = "0000"; @@ -823,5 +820,91 @@ namespace Backend.Controllers return apiResult; } + + /// + /// 更新forge_room room_id(dbid), room_name + /// + /// + [HttpPost] + public async Task> ImportForgeRoom([FromBody] List post) + { + ApiResult apiResult = new ApiResult(); + //var device_guid_record = ""; + try + { + if (post != null) + { + if (post.Count > 0) + { + //清空device_node資料表 + await backendRepository.TruncateTable("forge_room"); + + foreach (var idfc in post) + { + // var room_name_arr = idfc.room_name.Split('_'); + string full_name = idfc.room_name; + char first = full_name[0]; + if (first != 'B' && first != 'R' && first != 'U') + { + full_name = 'U' + full_name; + } + + //var param = new { floor_name = floor_name }; + + //房間 新增Data至forge_room資料表 + Dictionary room = new Dictionary(); + room.Add("@room_id", idfc.room_id); + room.Add("@deleted", 0); + room.Add("@room_name", full_name); + room.Add("@created_at", DateTime.Now); + + await backendRepository.AddOneByCustomTableReturnId(room, "forge_room", false); + + + } + + //更新forge_room資料表 building_tag, floor_guid欄位 + string sql = @" + update forge_room a + join ( + select building_tag, floor_guid, + case when right(floor_name, 1) = 'F' then floor_name + else CONCAT(floor_name, 'F') end floor_name , priority + from ( + SELECT + a.building_tag, + a.floor_guid, a.full_name, + case when left(a.full_name, 1) = 'B' then a.full_name + when left(a.full_name, 1) = 'R' then a.full_name + when left(a.full_name, 1) = 'U' then a.full_name + else CONCAT('U', a.full_name) end as floor_name, + a.priority + FROM floor AS a + INNER JOIN building AS b ON a.building_tag = b.building_tag + WHERE a.deleted = 0 AND b.deleted = 0 + )y + )x on SUBSTRING_INDEX(a.room_name, '_', 1) = x.floor_name + set a.building_tag = x.building_tag, + a.floor_guid = x.floor_guid"; + await backendRepository.ExecuteSql(sql); + } + apiResult.Code = "0000"; + apiResult.Msg = "編輯成功"; + } + else + { + apiResult.Code = "0001"; + apiResult.Msg = "無資料輸入"; + } + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } } } diff --git a/Backend/Models/Device.cs b/Backend/Models/Device.cs index 668e3f7..2d9dd3a 100644 --- a/Backend/Models/Device.cs +++ b/Backend/Models/Device.cs @@ -270,4 +270,23 @@ namespace Backend.Models public string device_coordinate_3d { get; set; } public int forge_dbid { get; set; } } + + public class ImportForgeRoom + { + public string building_tag { get; set; } + public string floor_guid { get; set; } + public int room_id { get; set; } + public int deleted { get; set; } + public string room_name { get; set; } + public string created_at { get; set; } + } + + public class Import_floor_data + { + public string building_tag { get; set; } + public string floor_guid { get; set; } + public string floor_name { get; set; } + public int priority { get; set; } + } + } diff --git a/Backend/wwwroot/forgeDemo.html b/Backend/wwwroot/forgeDemo.html index 6bbdccb..9751333 100644 --- a/Backend/wwwroot/forgeDemo.html +++ b/Backend/wwwroot/forgeDemo.html @@ -40,7 +40,7 @@ - +
@@ -240,7 +240,10 @@ //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA'); //雙模式 - launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA=='); + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA=='); + + //01.06 樓層刪除燈具 + launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQyVFOSU5QiU5OSVFNiVBOCVBMSVFNSVCQyU4RitNRVAlRTYlOEIlODYlRTclQjMlQkIlRTclQjUlQjFfJUU1JTg4JUFBJUU3JTg3JTg4JUU1JTg1JUI3XzIwMjNfMDFfMDYubndk'); //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC @@ -381,6 +384,7 @@ function importDevCor() { ImportDevForCor(); + ImportForgeRoom(); } function ImportDevForCor() {//callback = null @@ -412,9 +416,38 @@ fail: function (xhr, status, error) { } }); - } + function ImportForgeRoom() { + var url = "/DeviceImport/ImportForgeRoom"; + + $.ajax({ + method: "POST", + url: url, + data: JSON.stringify(roomDataList), + cache: false, + async: false, + contentType: "application/json; charset=UTF-8", + dataType: 'json', + success: function (rel) { + if (rel.code != "0000") { + if (rel.code == "9999") { + console.log(rel.msg); + } + else { + console.log(rel.msg); + } + return; + } + else { + console.log(rel.msg); + return; + } + }, + fail: function (xhr, status, error) { + } + }); + } diff --git a/Backend/wwwroot/js/forge/ForgeDemo.js b/Backend/wwwroot/js/forge/ForgeDemo.js index de1db6d..8032001 100644 --- a/Backend/wwwroot/js/forge/ForgeDemo.js +++ b/Backend/wwwroot/js/forge/ForgeDemo.js @@ -13,7 +13,8 @@ var levels;//剖面用 var baseApiUrl = "http://localhost:3604"; var instanceTree; //var objSendData = { Data: null }; -var tagIdDevList = []; +var tagIdDevList = [];//模型設備List: device_number、device_coordinate_3d、forge_dbid +var roomDataList = [];//模型房間List: room_id、room_name function launchViewer(urn) { var av = Autodesk.Viewing; @@ -274,39 +275,36 @@ function onDocumentLoadSuccess(doc) { e.properties.forEach(function (item) { if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】 if (item.displayValue != "") { - //if ((item.displayValue).indexOf('TPE_B1_ME_M10') > -1) { - console.log("--------------------------------------------------"); - console.log("Tag_name dbid: " + e.dbId); - console.log("value: " + item.displayValue); - - //myDataList.forEach((myData, index) => { - // devices.push({ id: index, position: JSON.parse(myData.device_coordinate_3d), sensorTypes: ["temperature", "humidity"] }); - //}); - //} - - let bounds = new THREE.Box3(); + ////if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10 + //console.log("--------------------------------------------------"); + //console.log("Tag_name dbid: " + e.dbId); + //console.log("value: " + item.displayValue); + ////} + var str = item.displayValue.split('_'); + if (str.length == 2) { //兩段為房間 ex: U7F_01 + roomDataList.push({ room_id: e.dbId, room_name: item.displayValue }); + } + else if (str.length == 8) { //八段為設備 ex: TPE_B1_ME_M10_U7F_NA_FCU_N1 + //取得座標 + let bounds = new THREE.Box3(); + instanceTree.enumNodeFragments(e.dbId, (fragId) => { + let box = new THREE.Box3(); + fragList.getWorldBounds(fragId, box); + bounds.union(box); + }, true); + var position = bounds.center(); + ////if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) { + //console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")"); + //console.log("--------------------------------------------------"); + ////} + tagIdDevList.push({ device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId }); + } - instanceTree.enumNodeFragments(e.dbId, (fragId) => { - let box = new THREE.Box3(); - fragList.getWorldBounds(fragId, box); - bounds.union(box); - }, true); - var position = bounds.center(); - //if ((item.displayValue).indexOf('TPE_B1_ME_M10') > -1) { - console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")"); - tagIdDevList.push({ device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId }); - console.log("--------------------------------------------------"); - //} } - //getFragmentWorldMatrixByNodeId(e.dbId, viewer); - //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - } }); - }) - }) //---------------------- end --------------------------------------------------- @@ -792,8 +790,6 @@ function setElevatorSpeed(speed) { //0.01 ~ 1 } function movElevator() { - - let tree = viewer.model.getData().instanceTree;//三組:(749,750,751),(755,756,757),(761,762,763) let nodeId = 12112;//12104; //749; //10952; let nodeId2 = 12111;//12105; //750; @@ -908,64 +904,6 @@ function hideColor(nodeId) {//顏色改成透明 viewer.setThemingColor(nodeId, color); } -//function movElevator() { - - -// let tree = viewer.model.getData().instanceTree; -// let nodeId = 750;// 10952; -// let fragProxyZ = 0; -// var movStatus = 0; // 0=no 1=up 2=down - - -// if (fragProxy.position.z > targetFloorZ) { -// movStatus = 2 -// } -// else if (fragProxy.position.z < targetFloorZ) { -// movStatus = 1 -// } - -// if (movStatus == 0) { -// return; -// } - -// tree.enumNodeFragments(nodeId, function (frag) { -// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); -// fragProxy.getAnimTransform(); -// //let fragPosition = new THREE.Vector3(0, 0, 15);// 一樓0 二樓15 三樓 26 -// if (movStatus == 2) { -// fragProxy.position.z -= elevatorSpeed; -// } -// else if (movStatus == 1) { -// fragProxy.position.z += elevatorSpeed; -// } - -// fragProxyZ = fragProxy.position.z; -// fragProxy.updateAnimTransform() - -// }); -// viewer.impl.sceneUpdated(true); - -// if (movStatus == 2) { -// if (fragProxyZ >= targetFloorZ) { -// requestAnimationFrame(movElevator); -// } -// } -// else if (movStatus == 1) { -// if (fragProxyZ <= targetFloorZ) { -// requestAnimationFrame(movElevator); -// } -// } - - -// //let fragPosition = new THREE.Vector3(position);// 一樓0 二樓15 三樓 26 - -// //fragProxy.position = fragPosition; - -// //fragProxy.updateAnimTransform(); - -// //viewer.impl.sceneUpdated(true); -//} - function getAllDbIds(viewer) { var instanceTree = viewer.model.getData().instanceTree; @@ -1025,10 +963,6 @@ function onButtonClicked() { this.viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]); } -function displayCuttedPlane() { - -} - /** * Autodesk.Viewing.Document.load() failuire callback. */ @@ -1082,27 +1016,7 @@ async function loadHeatmaps(model) { position: { x: 6.98, y: -2.24, z: 16.86 }, // x: 0, y: 25.03, z: -2.52 (-4.93, -3.85, 16.86) sensorTypes: ["temperature", "humidity"] } - - //{ - // id: "Oficina 5", - // //name: "Oficina-", - // position: { x: 3.35, y: -4.81, z: 12.88 }, // x: 0, y: 25, z: -2.5 (3.35, -4.81, 12.88 - // sensorTypes: ["temperature", "humidity"] - //}, - //{ - // id: "Oficina 4", - // //name: "Oficina-", - // position: { x: 37.03, y: -4.81, z: 12.88 }, // x: 0, y: 25.03, z: -2.52 (37.03, -4.81, 12.88) - // sensorTypes: ["temperature", "humidity"] - //}, - //{ - // id: "Oficina 3", - // //name: "Oficina-", - // position: { x: 2.83, y: -22.60, z: 12.88 }, // x: 0, y: 25.03, z: -2.52 (2.83, -22.60, 12.88) - // sensorTypes: ["temperature", "humidity"] - //} ]; - //冷氣N5: (6.98, -19.00, 16.86), N4: (35.85, -2.24, 16.86), N3: (6.98, -2.24, 16.86) // Initialize sensor values let sensorVals = []; @@ -1228,11 +1142,6 @@ async function loadHeatmap() { function hideObject() { //viewer.hide(4); - //viewer.hide(58); - //viewer.hide(613); - //viewer.hide(640); - //viewer.hide(560); - for (var i = 0; i < allDbIdsStr.length; i++) { viewer.hide(parseInt(allDbIdsStr[i])); } @@ -1240,11 +1149,6 @@ function hideObject() { function openObject() { //viewer.show(4); - //viewer.show(58); - //viewer.show(613); - //viewer.show(640); - //viewer.show(560); - for (var i = 0; i < allDbIdsStr.length; i++) { viewer.show(parseInt(allDbIdsStr[i])); } @@ -1252,67 +1156,11 @@ function openObject() { async function setObjectTransparent() { //setTransparency(4, 0); - //setTransparency(58, 0); - //setTransparency(613, 0); - //setTransparency(640, 0); - //setTransparency(560, 0); - //setTransparency(parseInt(515), 0); - - //for (var i = 0; i < allDbIdsStr.length; i++) { - // setTransparency(parseInt(allDbIdsStr[i]), 0); - //} - - //setTransparency(parseInt(515), 0); - //setTransparency(parseInt(516), 0); - //setTransparency(parseInt(517), 0); - //setTransparency(parseInt(518), 0); - //setTransparency(parseInt(519), 0); - //setTransparency(parseInt(399), 0); - //setTransparency(parseInt(101), 0); - //setTransparency(parseInt(100), 0); - //setTransparency(parseInt(58), 0); - - //setTransparency(parseInt(587), 0); - //setTransparency(parseInt(586), 0); - //setTransparency(parseInt(585), 0); - //setTransparency(parseInt(584), 0); - //setTransparency(parseInt(583), 0); - //setTransparency(parseInt(562), 0); - //setTransparency(parseInt(361), 0); - - //test(); - //hideColor(587); - //hideColor(586); - //hideColor(585); - //hideColor(584); - //hideColor(583); - //hideColor(562); - //hideColor(361); - setTransparentBuilding(); - } async function cancelObjectTransparent() { //setTransparency(4, 1); - //setTransparency(58, 1); - //setTransparency(613, 1); - //setTransparency(640, 1); - //setTransparency(560, 1); - //for (var i = 0; i < allDbIdsStr.length; i++) { - // setTransparency(parseInt(allDbIdsStr[i]), 1); - //} - - //setTransparency(515, 0.2); - //setTransparency(516, 0.2); - //setTransparency(517, 0.2); - //setTransparency(518, 0.2); - //setTransparency(519, 0.2); - //setTransparency(399, 0.2); - //setTransparency(101, 0.2); - //setTransparency(100, 0.2); - //setTransparency(58, 0.2); - recoverTransparentBuilding(); } @@ -1348,7 +1196,6 @@ async function test() { } - //------------ 剖面 ---------------------- async function getRemoteLevels() { const aecData = await Autodesk.Viewing.Document.getAecModelData(this.viewer.model.getDocumentNode()); @@ -1364,26 +1211,6 @@ async function getLevelsData() { this.levels = data; } -//function getCutPlaneParam(idx, n) { -// if (idx < 0 || !n) return; - -// const level = this.levels[idx]; -// if (!level) return; - -// //const precision = Autodesk.Viewing.Private.calculatePrecision( level.elevation ); -// const model = this.viewer.model; -// const globalOffset = model.getData().globalOffset; -// const units = model.getUnitString(); -// const elevRaw = Autodesk.Viewing.Private.convertUnits('ft', units, 1, level.elevation); - -// let d = elevRaw - globalOffset.z - 0.5; -// if (n == 1) -// d = -1 * d; - -// return new THREE.Vector4(0, 0, n, d); -//} - - function profile() { const upperIdx = 6; const upperCutPlaneParam = this.getCutPlaneParam(upperIdx, 1); @@ -1393,71 +1220,3 @@ function profile() { } //----------------- end ----------------------------------------------- -// 設備的dbid和3D座標 存進 資料庫 -//function ImportDevForCor() {//callback = null -// var url = "/DeviceImport/ImportDevForCor"; -// //let sendData = { -// // "device_number": pageAct.AreaTag, -// // "device_coordinate_3d": "", -// // "device_dbid": "", -// //}; -// objSendData.Data = tagIdDevList; -// //ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { -// // if (!res || res.code != "0000" || !res.data) { - -// // } else { - -// // } -// //}, null, "POST").send(); - -// //$.post(url, objSendData, function (rel) { -// // if (rel.code != "0000") { -// // if (rel.code == "9999") { -// // toast_error(rel.msg); -// // } -// // else { -// // toast_warning(rel.msg); -// // } -// // return; -// // } -// // else { -// // toast_ok(rel.msg); -// // //ReloadRawDataCheckTable(); -// // } - -// //}, 'json'); - -// //headers={'content-type': 'application/json'} - -// $.ajax({ -// type: "POST", -// url: url, -// data: objSendData, -// cache: false, -// contentType: 'application/json', -// processData: false, -// success: function (rel) { -// //$("#save-building-btn").html('確定').attr("disabled", false); -// if (rel.code != "0000") { -// if (rel.code == "9999") { -// toast_error(rel.msg); -// } -// else { -// toast_warning(rel.msg); -// } -// return; -// } -// else { -// toast_ok(rel.msg); -// //buildInfoTable.ajax.reload(null, false); -// //$('#build-modal').modal('hide'); -// return; -// } -// }, -// fail: function (xhr, status, error) { -// //$("#save-building-btn").html('確定').attr("disabled", false); -// //toast_error(rel.msg); -// } -// }); - -//} \ No newline at end of file From 241eb26adf1e7c3962384431c260547e102f1d6a Mon Sep 17 00:00:00 2001 From: GiteaAdmin Date: Sun, 8 Jan 2023 17:05:57 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E5=89=8D=E7=AB=AF=20iis=20=E7=94=A8=20we?= =?UTF-8?q?b.config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/Web.config | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Frontend/Web.config diff --git a/Frontend/Web.config b/Frontend/Web.config new file mode 100644 index 0000000..44aa1d6 --- /dev/null +++ b/Frontend/Web.config @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file From f4e837212dc817fdefb3853f76e3c90ec6ae03c1 Mon Sep 17 00:00:00 2001 From: GiteaAdmin Date: Sun, 8 Jan 2023 17:06:09 +0800 Subject: [PATCH 06/12] test --- FrontendWebApi/appsettings.Development.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index 18208df..7161e1e 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -6,10 +6,10 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "LoginExpireMinute": 3600, //nJɶA() + "LoginExpireMinute": 3600, //�n�J����ɶ��A���(��) "JwtSettings": { - "Issuer": "Admin", //oe - "SignKey": "TaipeiDome123456", //ñ//̤16r + "Issuer": "Admin", //�o�e�� + "SignKey": "TaipeiDome123456", //ñ��//�̤�16�r�� "JwtLifeSeconds": 3600 }, "DBConfig": { From 46f9ca1642adb734f80fcf81a898a07acb47482c Mon Sep 17 00:00:00 2001 From: wanli Date: Mon, 9 Jan 2023 16:32:28 +0800 Subject: [PATCH 07/12] =?UTF-8?q?[Frontend]=20=E5=87=BD=E5=BC=8F=E8=BC=B8?= =?UTF-8?q?=E5=85=A5=E6=9B=B4=E6=94=B9=E7=82=BAdevice=5Fguid:=20=E7=87=88?= =?UTF-8?q?=E5=85=89=E9=97=9C=E7=87=88=E3=80=81=E7=87=88=E5=85=89=E6=94=B9?= =?UTF-8?q?=E8=AE=8A=E9=A1=8F=E8=89=B2=E5=92=8C=E5=BC=B7=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_sysMonAll.html | 39 +++++++++++++ Frontend/js/forge/forgemodel.js | 99 +++++++++++++-------------------- 2 files changed, 79 insertions(+), 59 deletions(-) diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html index 72defa2..2dd6031 100644 --- a/Frontend/_sysMonAll.html +++ b/Frontend/_sysMonAll.html @@ -48,6 +48,7 @@ setLightColor(); } if (arr.indexOf(3) != -1) { + getLightPoint(); getHotspotPoint(() => { show3DModel(data.urn_3D); }); @@ -447,11 +448,49 @@ } + async function getLightPoint(callback = null) { + let url = baseApiUrl + "/api/GetDevNodeForCor"; + let sendData = { + "device_area_tag": pageAct.AreaTag, + "device_building_tag": pageAct.buiTag, + "device_system_tag": pageAct.sysMainTag, + "device_name_tag": pageAct.sysSubTag, + }; + objSendData.Data = sendData; + ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { + if (!res || res.code != "0000" || !res.data) { + + } else { + + let myDataList = []; + $.each(res.data, (idx, data) => { + let item = {}; + item.position = {}; + if (data.device_node_coordinate_3d != null && isJSON(data.device_node_coordinate_3d)) { + item.position = JSON.parse(data.device_node_coordinate_3d); + } + $.extend(item, data); + myDataList.push(item); + }) + + console.log("2", myDataList) + setLightPoint(myDataList); + callback ? callback() : ""; + } + }, null, "POST").send(); + + } + function setHotspotPoint(myDataList = []) { console.log(myDataList) getHopspotPoint(myDataList); } + async function setLightPoint(myDataList = []) { + console.log(myDataList) + getLightData(myDataList); + } + var parentEle = ""; onEvent("autodesk:click:sprite", "[name=forgeViewer]", function (e, obj) { forgeUnFocusAll(); diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js index a021bc5..cffbc8d 100644 --- a/Frontend/js/forge/forgemodel.js +++ b/Frontend/js/forge/forgemodel.js @@ -330,15 +330,6 @@ class elevator3D { } function onDocumentLoadSuccess(doc, eleOption) { - //取得燈光清單 - if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) { - lightDataList.forEach((myData, index) => { - //if (myData.priority == 5) { - const position = JSON.parse(myData.device_node_coordinate_3d); - lightList.push({ dbid: myData.forge_dbid, spotLight: newLight(position) }); - //} - }); - } var viewables = doc.getRoot().getDefaultGeometry(); viewer.loadDocumentNode(doc, viewables).then(i => { @@ -727,15 +718,26 @@ function hideColor(nodeId) {//顏色改成透明 } -//------------------ 紀錄熱點座標 --------------- -function getHopspotPoint(data) { - //var av = Autodesk.Viewing; - myDataList = data; - //viewer.addEventListener(av.GEOMETRY_LOADED_EVENT, addHotPoint, { - // once: true, - //}); +//紀錄燈具座標 +async function getLightData(data) { + lightDataList = data; +} + +async function testNewLight(dataList) { + dataList.forEach((myData, index) => { + const position = JSON.parse(myData.device_node_coordinate_3d); + lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10) }); + + lightList[index].lightObject.position.set(position.x, position.y, position.z); + lightList[index].lightObject.castShadow = true; + lightList[index].lightObject.visible = true; + lightList[index].lightObject.target.position.set(position.x, position.y, position.z - 20); + viewer.scene.add(lightList[index].lightObject.target); + viewer.scene.add(lightList[index].lightObject); + viewer.impl.sceneUpdated(true); + + }); } -//-------------------- end ---------------------- //------------------- 加入熱點 ----------------- async function addHotPoint(data) { @@ -753,13 +755,10 @@ async function addHotPoint(data) { const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon); - //取得燈光清單 - //if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) { - // lightDataList.forEach((myData, index) => { - // const position = JSON.parse(myData.device_node_coordinate_3d); - // lightList.push({ dbid: myData.forge_dbid, spotLight: newLight(position) }); - // }); - //} + if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) { + testNewLight(lightDataList); + } + //熱點 點擊事件註冊 viewer.addEventListener(DataVizCore.MOUSE_CLICK, onSpriteClicked);// SPRITE_SELECTED @@ -790,12 +789,16 @@ async function addHotPoint(data) { if (event != undefined && event != null) { if (event.dbId >= dbIdStart) {//event.dbId > 0 && event.dbId < 19 console.log(`Sprite clicked: ${event.dbId}`); - openHotspotModal(); + for (let i = dbIdStart; i <= myDataList.length + 10; i++) { changeColorForHotspot(i); changeScaleForHotspot(i, false); } let myData = myDataList.filter(x => x._dbId == event.dbId)[0]; + if (lightList != undefined && lightList != null && lightList.length > 0) { + //setLightOpenOrClose(false, myData.device_guid);//關燈測試 + //setLightValues(myData.device_guid, 20, 0x00ff00);//更改燈光顏色和強度的測試 + } $(selector).trigger("autodesk:click:sprite", { event, myData }); } else { $(selector).trigger("autodesk:clickOut:sprite", { event }); @@ -817,7 +820,6 @@ async function addHotPoint(data) { // if (dbIds.length > 0) { // // 處理已選取元件的邏輯 // $(selector).trigger("autodesk:click:sprite", event); - // //openHotspotModal(); // console.log(`------ name: ${viewer.model.getInstanceTree().getNodeName(dbIds)} , dbId: ${dbIds}`);//, id: ${event.clickInfo.object.id}, position.x: ${event.clickInfo.point.x}, y: ${event.clickInfo.point.y}, z: ${event.clickInfo.point.z} // } else { // // 處理沒有選取元件的邏輯 @@ -864,22 +866,7 @@ async function changeScaleForHotspot(dbId, type = true) { //------------------- end -------------- -//----------------- 開關熱點小視窗 ---------------------- -function openHotspotModal() { - //var modal = document.getElementById("hotspotModal"); - //modal.style.display = "block"; - //$("#pills-register-tab").removeClass("active"); - //$("#pills-alarm-tab").removeClass("active"); - //$("#pills-operation-tab").removeClass("active"); - //$("#pills-login-tab").tab("show"); -} -function closeHotspotModal() { - //var modal = document.getElementById("hotspotModal"); - //modal.style.display = "none"; - -} -//------------------ end -------------------------------- //------------------ 熱圖 ------------------------------- async function loadHeatmaps(model) { @@ -1118,25 +1105,24 @@ async function newLight(lightPosition) { } //調整燈光 強度、顏色 -async function setLightValues(dbid, intensity, color) { - for (var i = 0; i < lightList.length; i++) { - if (lightList[i].dbid == dbid) { - lightList[i].spotLight.intensity = intensity; - +async function setLightValues(deviceGuid, intensity, color) { + for (var i = 0; i < lightList.length; i++) { + if (lightList[i].device_guid == deviceGuid) { + lightList[i].lightObject.intensity = intensity; + var tempcolor = new THREE.Color().setHex(color); - lightList[i].spotLight.color = tempcolor; - viewer.impl.sceneUpdated(true); + lightList[i].lightObject.color = tempcolor; } } + viewer.impl.sceneUpdated(true); } //燈光開關 -function setLightOpenOrClose(value, light) { - if (value) { - light.visible = true; - } - else { - light.visible = false; +async function setLightOpenOrClose(value, deviceGuid) { + for (var i = 0; i < lightList.length; i++) { + if (lightList[i].device_guid == deviceGuid) { + lightList[i].lightObject.visible = value; + } } viewer.impl.sceneUpdated(true); } @@ -1173,11 +1159,6 @@ function getHopspotPoint(data) { myDataList = data; } -//紀錄燈具座標 -async function getLightData(data) { - lightDataList = data; -} - //呼叫載入熱圖 async function toLoadHeatmap(roomArr) { const model = viewer.model; From fac789c6351dbb41cfb20fe59f38ab2f90c228e8 Mon Sep 17 00:00:00 2001 From: wanli Date: Mon, 9 Jan 2023 17:09:44 +0800 Subject: [PATCH 08/12] =?UTF-8?q?[Frontend]=20=E5=A2=9E=E5=8A=A0=E5=87=BD?= =?UTF-8?q?=E5=BC=8F=20=E7=A7=BB=E5=8B=95=E8=A6=96=E8=A7=92=E8=87=B3?= =?UTF-8?q?=E8=A8=AD=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/js/forge/forgemodel.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js index cffbc8d..131ea89 100644 --- a/Frontend/js/forge/forgemodel.js +++ b/Frontend/js/forge/forgemodel.js @@ -726,7 +726,7 @@ async function getLightData(data) { async function testNewLight(dataList) { dataList.forEach((myData, index) => { const position = JSON.parse(myData.device_node_coordinate_3d); - lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10) }); + lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xffffff, 200, 20, 0.6, 0.5, 10) }); lightList[index].lightObject.position.set(position.x, position.y, position.z); lightList[index].lightObject.castShadow = true; @@ -798,6 +798,7 @@ async function addHotPoint(data) { if (lightList != undefined && lightList != null && lightList.length > 0) { //setLightOpenOrClose(false, myData.device_guid);//關燈測試 //setLightValues(myData.device_guid, 20, 0x00ff00);//更改燈光顏色和強度的測試 + moveViewToDevice(myData.forge_dbid);//移動視角至該設備 } $(selector).trigger("autodesk:click:sprite", { event, myData }); } else { @@ -1170,4 +1171,15 @@ function setShadowShow(type = false) { viewer.impl.sceneUpdated(true); } -//============================= end =================================== \ No newline at end of file +//============================= end =================================== + +function moveViewToDevice(letter) { + if (letter != "") { + viewer.clearSelection(); + viewer.select(letter); + viewer.fitToView([letter]); + } + else { + viewer.clearSelection(); + } +} \ No newline at end of file From aab47a13d4c307f8a933e71c550117ceb26b2c35 Mon Sep 17 00:00:00 2001 From: wanli Date: Mon, 9 Jan 2023 17:26:15 +0800 Subject: [PATCH 09/12] =?UTF-8?q?[Frontend]=20=E6=B8=AC=E8=A9=A6=E8=A8=AD?= =?UTF-8?q?=E5=82=99=E6=B8=85=E5=96=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/forgetTest2.html | 14 +- Frontend/js/forge/modeltest.js | 494 ++++++++++++++++----------------- 2 files changed, 258 insertions(+), 250 deletions(-) diff --git a/Frontend/forgetTest2.html b/Frontend/forgetTest2.html index 7eda69e..a937a3c 100644 --- a/Frontend/forgetTest2.html +++ b/Frontend/forgetTest2.html @@ -51,6 +51,7 @@
+
@@ -244,7 +245,7 @@ //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1pdHN1YmlzaGkvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU5JUExJUFGXzEyMjgubndk'); //12.30 整棟樓 ARC + MEP - launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8xMl8zMC5ud2Q'); + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8xMl8zMC5ud2Q'); //12.30 整棟樓 ARC + MEP 半透明 //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8lRTUlOEQlOEElRTklODAlOEYlRTYlOTglOEUlRTUlQkIlQkElRTclQUYlODlfMTJfMzAubndk'); @@ -254,8 +255,11 @@ //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC - + //01.06 加上room_id(樓層有燈具) + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIzXzAxXzA2Lm53ZA'); + //01.06 樓層刪除燈具 + launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQyVFOSU5QiU5OSVFNiVBOCVBMSVFNSVCQyU4RitNRVAlRTYlOEIlODYlRTclQjMlQkIlRTclQjUlQjFfJUU1JTg4JUFBJUU3JTg3JTg4JUU1JTg1JUI3XzIwMjNfMDFfMDYubndk'); }); //function move1Floor() { @@ -412,6 +416,10 @@ createHeatmapRect(labels, colorStops); } + function showList() { + consoleList(); + } + function createHeatmapRect(labels, colorStops) { if (!this.canvas) { return; @@ -438,7 +446,7 @@ context.fillRect(10, 20, 280, 20); } - + diff --git a/Frontend/js/forge/modeltest.js b/Frontend/js/forge/modeltest.js index 765fd66..44ae412 100644 --- a/Frontend/js/forge/modeltest.js +++ b/Frontend/js/forge/modeltest.js @@ -5,6 +5,7 @@ var elevatorSpeed; var allDbIdsStr; let bulbLight;//點燈 var spotLight;//聚光燈 +let testLight; var myDataList;//設備清單 var viewableData; var dataVizExtn; @@ -12,7 +13,9 @@ var spriteColorRed; var levels;//剖面用 var light; let pointLightHelper; - +var tagIdDevList = [];//模型設備List: device_number、device_coordinate_3d、forge_dbid +var roomDataList = [];//模型房間List: room_id、room_name + function launchViewer(urn) { var av = Autodesk.Viewing; var options = { @@ -139,12 +142,10 @@ function onDocumentLoadSuccess(doc) { viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () { - var instanceTree = viewer.model.getData().instanceTree; - - var domElem = document.getElementById('all_id'); - allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); - domElem.innerText = allDbIdsStr; - + var instanceTree = viewer.model.getData().instanceTree; + var domElem = document.getElementById('all_id'); + allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); + domElem.innerText = allDbIdsStr; //parseInt(allDbIdsStr[i] //for (var i = 0; i < allDbIdsStr.length; i++) { // //setTransparency(parseInt(allDbIdsStr[i]), 0.2); @@ -161,105 +162,152 @@ function onDocumentLoadSuccess(doc) { // }) //} - // ------------------ 取得tag_id底下的nodeId -------------------------------------- - var curDbId = 0; - var tagId = 0; - var _parentId = 0; - var _childId = 0; - var itemName = ''; - var childIdArr = new Array(); - let evelMap = new Map(); + //// ------------------ 取得tag_id底下的nodeId -------------------------------------- + //var curDbId = 0; + ////var tagId = 0; + ////var _parentId = 0; + ////var _childId = 0; + ////var itemName = ''; + ////var childIdArr = new Array(); + ////let evelMap = new Map(); - let tree = viewer.model.getData().instanceTree; - const model = viewer.model; - const fragList = model.getFragmentList(); + //let tree = viewer.model.getData().instanceTree; + //const model = viewer.model; + //const fragList = model.getFragmentList(); - //loadHeatmaps(model); + // //loadHeatmaps(model); + ////allDbIdsStr.forEach((dbId) => { + //// curDbId = parseInt(dbId); + //// viewer.getProperties(curDbId, function (e) { + //// e.properties.forEach(function (item) { + //// if (item.displayName == "tag_id" && e.name == "【電梯】") { + + //// //getFragmentWorldMatrixByNodeId(e.dbId, viewer); + //// //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + + //// tree.enumNodeFragments(e.dbId, function (frag) { + + //// let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + //// let matrix = new THREE.Matrix4(); + //// console.log("proxy: " + fragProxy.position); + + //// fragProxy.getWorldMatrix(matrix); + + //// }); + + + + //// tagId = e.dbId; + //// viewer.getProperties(tagId, function (e2) { + //// e2.properties.forEach(function (item2) { + //// if (item2.displayName == "child") { + //// _parentId = item2.displayValue; + + //// viewer.getProperties(_parentId, function (e3) { + //// let itemMap = new Map(); + //// e3.properties.forEach(function (item3) { + //// if (item3.displayName == "child") { + //// _childId = item3.displayValue; + //// childIdArr.push(_childId); + + //// var n = 0; + //// viewer.getProperties(childIdArr[n], function (e5) { + //// e5.properties.forEach(function (item5) { + //// if (item5.displayName == "Name") { + //// itemName = item5.displayValue; + //// itemMap.set(childIdArr[0], itemName) + //// console.log("childIdArr[0] ", childIdArr[0]) + //// console.log("item name: ", itemName); + //// n += 3; + //// } + //// }); + //// }) + + //// n = 1; + //// viewer.getProperties(childIdArr[n], function (e6) { + //// e6.properties.forEach(function (item6) { + //// if (item6.displayName == "Name") { + //// itemName = item6.displayValue; + //// itemMap.set(childIdArr[1], itemName) + //// console.log("childIdArr[1] ", childIdArr[1]) + //// console.log("item name: ", itemName); + //// n += 3; + //// } + //// }); + //// }) + + //// n = 2; + //// viewer.getProperties(childIdArr[n], function (e7) { + //// e7.properties.forEach(function (item7) { + //// if (item7.displayName == "Name") { + //// itemName = item7.displayValue; + //// itemMap.set(childIdArr[2], itemName) + //// console.log("childIdArr[2] ", childIdArr[2]) + //// console.log("item name: ", itemName); + //// n += 3; + //// } + //// }); + //// }) + + //// } + //// }); + //// evelMap.set(item.displayValue, itemMap) + //// }) + + //// } + //// }); + //// }) + //// } + //// }); + + //// }) + + ////}) + //allDbIdsStr.forEach((dbId) => { // curDbId = parseInt(dbId); // viewer.getProperties(curDbId, function (e) { // e.properties.forEach(function (item) { - // if (item.displayName == "tag_id" && e.name == "【電梯】") { + // if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】 + // if (item.displayValue != "") { + // if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10 + // console.log("--------------------------------------------------"); + // console.log("Tag_name dbid: " + e.dbId); + // console.log("value: " + item.displayValue); + // } + // //var v = getFragmentWorldMatrixByNodeId(e.dbId, viewer); + // //console.log("v: " + v); + + // //tree.enumNodeFragments(e.dbId, function (frag) { + // // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + // // fragProxy.getAnimTransform(); + // // console.log("postion: " + fragProxy.position + ", fragP: " + fragProxy.fragPosition); + // //}); + + + + // let bounds = new THREE.Box3(); + + // instanceTree.enumNodeFragments(e.dbId, (fragId) => { + // let box = new THREE.Box3(); + // fragList.getWorldBounds(fragId, box); + // bounds.union(box); + // }, true); + // var position = bounds.center(); + // if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) { + // console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")"); + // console.log("--------------------------------------------------"); + // } + // } // //getFragmentWorldMatrixByNodeId(e.dbId, viewer); // //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - // tree.enumNodeFragments(e.dbId, function (frag) { - // let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - // let matrix = new THREE.Matrix4(); - // console.log("proxy: " + fragProxy.position); - - // fragProxy.getWorldMatrix(matrix); - - // }); - - - - // tagId = e.dbId; - // viewer.getProperties(tagId, function (e2) { - // e2.properties.forEach(function (item2) { - // if (item2.displayName == "child") { - // _parentId = item2.displayValue; - - // viewer.getProperties(_parentId, function (e3) { - // let itemMap = new Map(); - // e3.properties.forEach(function (item3) { - // if (item3.displayName == "child") { - // _childId = item3.displayValue; - // childIdArr.push(_childId); - - // var n = 0; - // viewer.getProperties(childIdArr[n], function (e5) { - // e5.properties.forEach(function (item5) { - // if (item5.displayName == "Name") { - // itemName = item5.displayValue; - // itemMap.set(childIdArr[0], itemName) - // console.log("childIdArr[0] ", childIdArr[0]) - // console.log("item name: ", itemName); - // n += 3; - // } - // }); - // }) - - // n = 1; - // viewer.getProperties(childIdArr[n], function (e6) { - // e6.properties.forEach(function (item6) { - // if (item6.displayName == "Name") { - // itemName = item6.displayValue; - // itemMap.set(childIdArr[1], itemName) - // console.log("childIdArr[1] ", childIdArr[1]) - // console.log("item name: ", itemName); - // n += 3; - // } - // }); - // }) - - // n = 2; - // viewer.getProperties(childIdArr[n], function (e7) { - // e7.properties.forEach(function (item7) { - // if (item7.displayName == "Name") { - // itemName = item7.displayValue; - // itemMap.set(childIdArr[2], itemName) - // console.log("childIdArr[2] ", childIdArr[2]) - // console.log("item name: ", itemName); - // n += 3; - // } - // }); - // }) - - // } - // }); - // evelMap.set(item.displayValue, itemMap) - // }) - - // } - // }); - // }) // } // }); @@ -267,54 +315,64 @@ function onDocumentLoadSuccess(doc) { //}) - allDbIdsStr.forEach((dbId) => { - curDbId = parseInt(dbId); - viewer.getProperties(curDbId, function (e) { - e.properties.forEach(function (item) { - if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】 - if (item.displayValue != "") { - if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10 - console.log("--------------------------------------------------"); - console.log("Tag_name dbid: " + e.dbId); - console.log("value: " + item.displayValue); + ////---------------------- end --------------------------------------------------- + + // ------------------ 2023.01.06 取得tag_id、底下的nodeId -------------------------------------- + var curDbId = 0; + + let tree = viewer.model.getData().instanceTree; + const model = viewer.model; + const fragList = model.getFragmentList(); + + + allDbIdsStr.forEach((dbId) => { + curDbId = parseInt(dbId); + viewer.getProperties(curDbId, function (e) { + e.properties.forEach(function (item) { + if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】 + if (item.displayValue != "") { + ////if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10 + //console.log("--------------------------------------------------"); + //console.log("Tag_name dbid: " + e.dbId); + //console.log("value: " + item.displayValue); + ////} + var str = item.displayValue.split('_'); + if (str.length == 2) { //兩段為房間 ex: U7F_01 + roomDataList.push({ room_id: e.dbId, room_name: item.displayValue }); + } + else if (str.length == 8) { //八段為設備 ex: TPE_B1_ME_M10_U7F_NA_FCU_N1 + //取得座標 + let bounds = new THREE.Box3(); + instanceTree.enumNodeFragments(e.dbId, (fragId) => { + let box = new THREE.Box3(); + fragList.getWorldBounds(fragId, box); + bounds.union(box); + }, true); + var position = bounds.center(); + ////if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) { + //console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")"); + //console.log("--------------------------------------------------"); + ////} + tagIdDevList.push({ device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId }); + } + + + + + + + + } - //var v = getFragmentWorldMatrixByNodeId(e.dbId, viewer); - //console.log("v: " + v); - //tree.enumNodeFragments(e.dbId, function (frag) { - // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - // fragProxy.getAnimTransform(); - // console.log("postion: " + fragProxy.position + ", fragP: " + fragProxy.fragPosition); - //}); - - - - let bounds = new THREE.Box3(); - - instanceTree.enumNodeFragments(e.dbId, (fragId) => { - let box = new THREE.Box3(); - fragList.getWorldBounds(fragId, box); - bounds.union(box); - }, true); - var position = bounds.center(); - if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) { - console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")"); - console.log("--------------------------------------------------"); - } } - //getFragmentWorldMatrixByNodeId(e.dbId, viewer); - //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + }); - - } - }); + }) }) - - }) - - //---------------------- end --------------------------------------------------- + //---------------------- end --------------------------------------------------- @@ -359,116 +417,51 @@ function onDocumentLoadSuccess(doc) { // }) //}) - - //let tree = viewer.model.getData().instanceTree; - let nodeId = 12112;//12104; //749; //10952; - let nodeId2 = 12111;//12105; //750; - let nodeId3 = 12110;//12104; //751; - tree.enumNodeFragments(nodeId, function (frag) { - fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - fragProxy.getAnimTransform(); - let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 - fragProxy.position = fragPosition + // //let tree = viewer.model.getData().instanceTree; + //let nodeId = 12112;//12104; //749; //10952; + //let nodeId2 = 12111;//12105; //750; + //let nodeId3 = 12110;//12104; //751; - fragProxy.updateAnimTransform() + //tree.enumNodeFragments(nodeId, function (frag) { + // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + // fragProxy.getAnimTransform(); + // let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + // fragProxy.position = fragPosition + // fragProxy.updateAnimTransform() + //}); + //viewer.impl.sceneUpdated(true); - }); - viewer.impl.sceneUpdated(true); + ////------------ add ------------- + //tree.enumNodeFragments(nodeId2, function (frag) { + // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + // fragProxy.getAnimTransform(); + // let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 - //------------ add ------------- - tree.enumNodeFragments(nodeId2, function (frag) { - fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - fragProxy.getAnimTransform(); - let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + // fragProxy.position = fragPosition - fragProxy.position = fragPosition + // fragProxy.updateAnimTransform() - fragProxy.updateAnimTransform() + //}); + //viewer.impl.sceneUpdated(true); - }); - viewer.impl.sceneUpdated(true); + //tree.enumNodeFragments(nodeId3, function (frag) { + // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + // fragProxy.getAnimTransform(); + // let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 - tree.enumNodeFragments(nodeId3, function (frag) { - fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - fragProxy.getAnimTransform(); - let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + // fragProxy.position = fragPosition - fragProxy.position = fragPosition + // fragProxy.updateAnimTransform() - fragProxy.updateAnimTransform() - - }); - viewer.impl.sceneUpdated(true); + //}); + //viewer.impl.sceneUpdated(true); }); - - //add toolbar fail - //function ToolbarExtension(viewer, options) { - // Autodesk.Viewing.Extension.call(this, viewer, options); - //} - - //ToolbarExtension.prototype = Object.create(Autodesk.Viewing.Extension.prototype); - //ToolbarExtension.prototype.constructor = ToolbarExtension; - - //ToolbarExtension.prototype.load = function () { - // this.viewer.setLightPreset(6); - // this.viewer.setEnvMapBackground(true); - // this.viewer.fitToView(); - // return true; - //}; - - //ToolbarExtension.prototype.unload = function () { - - //}; - //Autodesk.Viewing.theExtensionManager.registerExtension('ToolbarExtension', ToolbarExtension); - - //ToolbarExtension.prototype.onToolbarCreated = function (toolbar) { - // //alert('TODO: customize Viewer toolbar'); - - // var viewer = this.viewer; - // var button1 = new Autodesk.Viewing.UI.Button('show-env-bg-button'); - // button1.onClick = function (e) { - // viewer.setEnvMapBackground(true); - // }; - // button1.addClass('show-env-bg-button'); - // button1.setToolTip('Show Environment'); - - // //SubToolbar - // this.subToolbar = new Autodesk.Viewing.UI.ControlGroup('my-custom-toolbar'); - // this.subToolbar.addControl(button1); - // toolbar.addControl(this.subToolbar); - - //}; - - - //加入點燈光 - //bulbLight = new THREE.PointLight(0xffffff, 1, 1, 2);//0xff0000 - //bulbLight.position.set(-17.33, 51.03, -2.52);//17.880840301513672 - //bulbLight.castShadow = true; - //bulbLight.intensity = 50; - //bulbLight.distance = 1; - //bulbLight.emissiveIntensity = bulbLight.intensity / Math.pow(0.02, 2.0); - //viewer.scene.add(bulbLight); - - //聚光燈 - //spotLight = new THREE.SpotLight(0xffff00, 80, 10);//0xffffff - //spotLight.position.set(-7.58, 18.20, -0.25); //set(-17.33, 51.03, -2.52); - //spotLight.castShadow = true; - //spotLight.visible = true; - //var geom = new THREE.BoxGeometry(); //create 幾何對象 -17.33, 51.03, -4.52 - //var material = new THREE.MeshLambertMaterial({ color: 0xffff00 });//0xff0000 - //var cube = new THREE.Mesh(geom, material); - //cube.position.set(-7.58, 18.20, -1); //set(-17.33, 51.03, -10);//-4.52 - //viewer.scene.add(cube); - //spotLight.target = cube; - //viewer.scene.add(spotLight); - - //light = newLight(); - newLight(); - + //newLight(); + //testLight = new THREE.SpotLight(); } //------------------- 加入熱點 ----------------- @@ -482,7 +475,8 @@ async function addHotPoint(data) { const spriteIcon = "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/circle.svg"; //"/img/forge/hotspot.svg"; const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon); - var a = newLight(); + //var a = newLight(); + newLight(); //function onSpriteClicked(event) { // console.log(`Sprite clicked: ${event.dbId}`); //} @@ -521,7 +515,7 @@ async function addHotPoint(data) { event.hasStopped = true; if (event != undefined && event != null) { if (event.dbId >= 10 && event.dbId <= 13) {//event.dbId > 0 && event.dbId < 19 - setLightValues(20, 0x00ff00) + setLightValues(20, 0x00ff00); console.log(`Sprite clicked: ${event.dbId}`); openHotspotModal(); } @@ -1387,26 +1381,26 @@ async function newLight() { //angle - 光從其上界為 Math.PI / 2 的方向散射的最大角度。 //半影 - 由於半影而衰減的聚光燈錐體的百分比。取值介於 0 和 1 之間。默認值為零。 //decay - 光沿光的距離變暗的量。 - //spotLight = new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10);//0xffffff 80, 10 //15, 20 , Math.PI / 12 - //spotLight.position.set(43.72, -15.65, -44.96); //set(-17.33, 51.03, -2.52); // -7.58, 18.20, -0.25 -44.96 - //spotLight.castShadow = false; - //spotLight.visible = true; + spotLight = new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10);//0xffffff 80, 10 //15, 20 , Math.PI / 12 + spotLight.position.set(43.72, -15.65, -44.96); //set(-17.33, 51.03, -2.52); // -7.58, 18.20, -0.25 -44.96 + spotLight.castShadow = false; + spotLight.visible = true; - //spotLight.target.position.set(43.72, -15.65, -60);// -15.65 -48 - //viewer.scene.add(spotLight.target); + spotLight.target.position.set(43.72, -15.65, -60);// -15.65 -48 + viewer.scene.add(spotLight.target); - //viewer.scene.add(spotLight); + viewer.scene.add(spotLight); - //viewer.impl.sceneUpdated(true); + viewer.impl.sceneUpdated(true); //return spotLight; //加入點燈光 - bulbLight = new THREE.PointLight(0xff0000, 50, 20, 2);//0xff0000 - bulbLight.position.set(43.72, -15.65, -44.96);//17.880840301513672 - bulbLight.castShadow = true; - bulbLight.visible = true; - viewer.scene.add(bulbLight); + //bulbLight = new THREE.PointLight(0xffffff, 50, 20, 2);//0xff0000 + //bulbLight.position.set(43.72, -15.65, -44.96);//17.880840301513672 + //bulbLight.castShadow = true; + //bulbLight.visible = true; + //viewer.scene.add(bulbLight); //pointLightHelper = new THREE.PointLightHelper(pointLight); //viewer.scene.add(pointLightHelper); @@ -1439,13 +1433,15 @@ function setLightValues(intensity, color) {// distance, angle, penumbra, decay, function setLightOpenOrClose(value) {//, light if (value) { //light.visible = true; - //spotLight.visible = true; - bulbLight.visible = true; + spotLight.visible = true; + //bulbLight.visible = true; + //testLight.visible = true; } else { //light.visible = false; - //spotLight.visible = false; - bulbLight.visible = false; + spotLight.visible = false; + //bulbLight.visible = false; + //testLight.visible = false; } viewer.impl.sceneUpdated(true); } @@ -1457,3 +1453,7 @@ function setLightTransparency(value) { } //------------- end ----------------------------------- +function consoleList() { + console.log(tagIdDevList); + console.log(roomDataList); +} \ No newline at end of file From 571130c2bfed797d15c31457a7d9be104120fc23 Mon Sep 17 00:00:00 2001 From: dev01 Date: Mon, 9 Jan 2023 19:15:27 +0800 Subject: [PATCH 10/12] =?UTF-8?q?[Frontend][=E5=85=A8=E5=9F=9F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD]=20YTTab=20=E7=A8=8B=E5=BA=8F=E8=AA=BF=E6=95=B4=20|?= =?UTF-8?q?=20[=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7]=20=E6=BA=AB=E5=BA=A6?= =?UTF-8?q?=E6=A2=9Dui=E8=A3=9C=E4=B8=8A=20|=20=E8=87=AA=E5=8B=95=E9=A0=88?= =?UTF-8?q?=E9=87=8F=E7=B7=A8=E8=BC=AF=E7=A8=8B=E5=BA=8F=E5=BB=BA=E7=BD=AE?= =?UTF-8?q?=20|=20=E8=87=AA=E5=8B=95=E9=A0=88=E9=87=8F=E5=9C=96=E8=A1=A8?= =?UTF-8?q?=E5=BB=BA=E7=BD=AE=20|=20[FrontendWebApi]=20GetAutDemVal=20vari?= =?UTF-8?q?able=20automated=5Fdemand=5Fresponse=20=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E9=A0=88=E9=87=8F=20api=20=E5=BB=BA=E7=BD=AE?= =?UTF-8?q?=20|=20=E7=B7=A8=E8=BC=AF=E8=87=AA=E5=8B=95=E9=A0=88=E9=87=8F?= =?UTF-8?q?=20api=20=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_sysMonAll.html | 23 +++++-- Frontend/css/site.css | 14 ++++ Frontend/index.html | 45 +++++++++---- Frontend/js/forge/forgemodel.js | 38 ++++++++++- Frontend/js/site.js | 40 ++++++++++-- Frontend/js/style.js | 34 +++++++++- .../yourteam/plugins/yt-navbar/yt-navbar.js | 2 +- Frontend/js/yourteam/plugins/yt-tab/yt-tab.js | 65 +++++++++++++++++-- 8 files changed, 231 insertions(+), 30 deletions(-) diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html index 72defa2..0e2778f 100644 --- a/Frontend/_sysMonAll.html +++ b/Frontend/_sysMonAll.html @@ -74,7 +74,10 @@
`; break; case 3: - strHtml = `
`; + strHtml = `
+ ${setTopHeatBar()} +
+
`; break; } @@ -92,11 +95,12 @@ } myBaja.setSubscribeDevicesByBql(ordPath); myBaja.setSubscribeDevicesCallBack(function (data) { - + console.log(data) let matchDevice = allDevList.filter(x => x.device_number == data.device_number_full)[0]; if (!matchDevice) { return false; } + console.log(data) //將訂閱值塞入 subDeviceData if (subDeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) { let obj = {}; @@ -142,10 +146,10 @@ }); } + function lightDevForgeSpotLig(devObj) { - let position = isJSON(devObj.device_coordinate_3d) ? JSON.parse(devObj.device_coordinate_3d) : {}; - newLight(position); + } // 從設備訂閱更新每個設備卡片即時點位 @@ -211,6 +215,12 @@ return strHtml; } + // 設置 Forge 3D 溫度條 + function setTopHeatBar() { + let strHtml = ``; + return strHtml; + } + // forge 3D 異常點位變紅色 function setForgeHotSpotColor(device) { let subData = subDeviceData.filter(x => x.device_number == device.device_number)[0] @@ -331,14 +341,19 @@
` return strHtml; } + function iframeResize(obj) { obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px'; } + function show3DModel(urn) { $(loadEle).Loading("start"); + getLightData(allDevList); launchViewerForHotspot(urn, (viewer, nodeIds) => { + showHeat("[name=forgeHeatBar]"); let devDbIds = allDevList.map(x => x.forge_dbid); /*hideAllObjects(devDbIds);*/ + setTransparentBuilding(0, devDbIds); $(loadEle).Loading("close"); diff --git a/Frontend/css/site.css b/Frontend/css/site.css index 8258bc3..a878acc 100644 --- a/Frontend/css/site.css +++ b/Frontend/css/site.css @@ -93,6 +93,20 @@ input:-webkit-autofill { background-color: rgba(0, 0, 0, 0.15) !important; } .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%;} +/*a[data-tabname="topFunBtn"] { color: #fff } + +a[data-tabname="topFunBtn"].active { color: #886ab5 } +a[data-tabname="topFunBtn"]:hover { color: var(--theme-primary-50); } + +.userblock { + color:#fff; +} +.userblock:hover { color: var(--theme-primary-50); } +.dropdown.show .userblock { color: var(--theme-primary-50) !important; }*/ +.page-header a {color:#fff !important;} +.page-header a:hover { color: var(--theme-primary-50) !important; } +.page-header a.active { color: var(--theme-primary-500) !important; } +.dropdown.show a { color: var(--theme-primary-50) !important; } @media screen and (max-width: 576px) { .yt-left-navbar { width: 100%; max-width: 100%; margin-top: 0; } } diff --git a/Frontend/index.html b/Frontend/index.html index b097139..f3eeba6 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -180,7 +180,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li