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; } + + } }