From da9b6f678d3c23d7e0354e8109321e56d7ed353f Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 17 May 2023 09:29:51 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/HiNetController.cs | 2 +- .../ApiControllers/HistoryController.cs | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HiNetController.cs b/FrontendWebApi/ApiControllers/HiNetController.cs index c92fe46..6eba35a 100644 --- a/FrontendWebApi/ApiControllers/HiNetController.cs +++ b/FrontendWebApi/ApiControllers/HiNetController.cs @@ -120,7 +120,7 @@ namespace FrontendWebApi.ApiControllers /// /// HiNet企業簡訊 Hiair .Net Core API /// - public class HiNetController : MyBaseApiController + public class HiNetController : MyBaseApiController { private readonly IBackendRepository backendRepository; public Socket socket; diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index 289a63c..52199d9 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -1118,27 +1118,27 @@ namespace FrontendWebApi.ApiControllers { //依據被選擇的設備找出相對應資料 var sqlDeviceItemInfo = $@"select - b.full_name as building_name, - v1.system_key as Main_system_name, - v2.system_key as Sub_system_name, - temp.device_number, - temp.device_name, - temp.full_name as item_name, - temp.points, - temp.unit - from ( - select - di.*, - d.device_number, - d.full_name as device_name, - d.priority - from device_item di - inner join device d on di.device_building_tag COLLATE utf8mb4_unicode_ci = d.device_building_tag - and di.device_system_tag COLLATE utf8mb4_unicode_ci = d.device_system_tag - and di.device_name_tag COLLATE utf8mb4_unicode_ci = d.device_name_tag - and d.deleted = 0 - where di.deleted = 0 and di.unit is not null and d.device_number IN @Device_number - ) temp + b.full_name as building_name, + v1.system_key as Main_system_name, + v2.system_key as Sub_system_name, + temp.device_number, + temp.device_name, + temp.full_name as item_name, + temp.points, + temp.unit + from ( + select + di.*, + d.device_number, + d.full_name as device_name, + d.priority + from device_item di + inner join device d on di.device_building_tag COLLATE utf8mb4_unicode_ci = d.device_building_tag + and di.device_system_tag COLLATE utf8mb4_unicode_ci = d.device_system_tag + and di.device_name_tag COLLATE utf8mb4_unicode_ci = d.device_name_tag + and d.deleted = 0 + where di.deleted = 0 and di.unit is not null and d.device_number IN @Device_number + ) temp inner join building b on temp.device_building_tag COLLATE utf8mb4_unicode_ci = b.building_tag and b.deleted = 0 inner join variable v1 on temp.device_system_tag COLLATE utf8mb4_unicode_ci = v1.system_value and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' inner join variable v2 on temp.device_name_tag COLLATE utf8mb4_unicode_ci = v2.system_value and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' From 8840d501ed503e9d6fceab867f99f3bb1b7a55be Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 17 May 2023 10:41:47 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=88=A4=E6=96=B7table=E5=AD=98=E5=9C=A8=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/HistoryController.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index 52199d9..d72c193 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -1148,21 +1148,24 @@ namespace FrontendWebApi.ApiControllers { var device_number = hi.Device_number_point.Split(":")[0]; var point = hi.Device_number_point.Split(":")[1]; - //var tableName = await backgroundServiceMsSqlRepository.GetAllAsync($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{device_number}%'"); - var device_item_infos = await frontendRepository.GetAllAsync(sqlDeviceItemInfo, new { Device_number = hi.Device_number_point }); + var tableName = await backgroundServiceMsSqlRepository.GetOneAsync($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{device_number}_{point}%'"); + if (!string.IsNullOrEmpty(tableName)) + { + var device_item_infos = await frontendRepository.GetAllAsync(sqlDeviceItemInfo, new { Device_number = hi.Device_number_point }); - var device_item_info = device_item_infos.Where(x => x.Device_number == device_number && x.Points == point).FirstOrDefault(); + var device_item_info = device_item_infos.Where(x => x.Device_number == device_number && x.Points == point).FirstOrDefault(); - var sql = $@"select '{device_item_info.Building_name}' as Building_name, '{device_item_info.Main_system_name}' as Main_system_name, - '{device_item_info.Sub_system_name}' as Sub_system_name', {device_item_info.Device_number}' as Device_number, - '{device_item_info.Device_name}' as Device_name, '{device_item_info.Item_name}' as Item_name, '{device_item_info.Points}' as Points, - '{device_item_info.Unit}' as Unit, timestamp as Timestamp, round(value, 2) as Value - from FIC_CENTER_{device_number}_{point} - where replace(convert(varchar, [timestamp], 111), '/', '-') >= @startTime - and replace(convert(varchar, [timestamp], 111), '/', '-') <= @endTime order by timestamp"; - apiResult.Data.AddRange( - await backgroundServiceMsSqlRepository.GetAllAsync(sql, new { startTime = input.Start_timestamp, endTime = input.End_timestamp }) - ); + var sql = $@"select '{device_item_info.Building_name}' as Building_name, '{device_item_info.Main_system_name}' as Main_system_name, + '{device_item_info.Sub_system_name}' as Sub_system_name', {device_item_info.Device_number}' as Device_number, + '{device_item_info.Device_name}' as Device_name, '{device_item_info.Item_name}' as Item_name, '{device_item_info.Points}' as Points, + '{device_item_info.Unit}' as Unit, timestamp as Timestamp, round(value, 2) as Value + from FIC_CENTER_{device_number}_{point} + where replace(convert(varchar, [timestamp], 111), '/', '-') >= @startTime + and replace(convert(varchar, [timestamp], 111), '/', '-') <= @endTime order by timestamp"; + apiResult.Data.AddRange( + await backgroundServiceMsSqlRepository.GetAllAsync(sql, new { startTime = input.Start_timestamp, endTime = input.End_timestamp }) + ); + } //foreach (var tn in tableName) //{ //} From 48dfbe134cb038720381da392e4c5d860f48594d Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 17 May 2023 11:42:27 +0800 Subject: [PATCH 3/6] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E5=AE=8C=E6=88=90hi?= =?UTF-8?q?net=E7=A8=8B=E5=BA=8F,=20=E4=BF=AE=E6=94=B9historyData=20loadta?= =?UTF-8?q?ble=20=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_historyData.html | 78 +++++++++---------- .../ApiControllers/HiNetController.cs | 33 ++++++-- 2 files changed, 65 insertions(+), 46 deletions(-) diff --git a/Frontend/_historyData.html b/Frontend/_historyData.html index ae0d194..0f79cb0 100644 --- a/Frontend/_historyData.html +++ b/Frontend/_historyData.html @@ -393,46 +393,46 @@ // console.log("loadTable",pageAct.devicePoiName.split(" ")[0]) v.type = pageAct.devicePoiName.split(" ")[0]; }); + + let tag = "#historyTable"; + + let column_defs = [ + { "targets": [0], "width": "20%", "sortable": true }, + { "targets": [1], "width": "20%", "sortable": true }, + { "targets": [2], "width": "20%", "sortable": true } + ]; + + let columns = [ + { + "title": "類別", + "data": "type" + }, + { + "title": "設備名稱", + "data": "deviceName", + }, + { + "title": "數值", + "data": "value", + "render": function (data) { + if (isNaN(data.toString())) { + return data + } + return data.roundDecimal(2); + } + }, + { + "title": "紀錄時間", + "data": "timestamp", + "render": function (data) { + // console.log(data) + return displayDate(data, "datetime"); + } + } + ]; + + historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); } - - let tag = "#historyTable"; - - let column_defs = [ - { "targets": [0], "width": "20%", "sortable": true }, - { "targets": [1], "width": "20%", "sortable": true }, - { "targets": [2], "width": "20%", "sortable": true } - ]; - - let columns = [ - { - "title": "類別", - "data": "type" - }, - { - "title": "設備名稱", - "data": "deviceName", - }, - { - "title": "數值", - "data": "value", - "render": function (data) { - if (isNaN(data.toString())) { - return data - } - return data.roundDecimal(2); - } - }, - { - "title": "紀錄時間", - "data": "timestamp", - "render": function (data) { - // console.log(data) - return displayDate(data, "datetime"); - } - } - ]; - - historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); } function exportExcel() { diff --git a/FrontendWebApi/ApiControllers/HiNetController.cs b/FrontendWebApi/ApiControllers/HiNetController.cs index 6eba35a..a5cc095 100644 --- a/FrontendWebApi/ApiControllers/HiNetController.cs +++ b/FrontendWebApi/ApiControllers/HiNetController.cs @@ -9,6 +9,8 @@ using FrontendWebApi.Models; using Microsoft.CodeAnalysis.CSharp.Syntax; using Repository.BackendRepository.Interface; using System.Linq; +using System.Threading; +using System.Collections.Generic; /// /// HiNet 企業簡訊 API for .NetCore 2.0 @@ -767,11 +769,11 @@ namespace FrontendWebApi.ApiControllers public ActionResult> HiNetMsg([FromBody] HiNetInput input) { ApiResult apiResult = new ApiResult(jwt_str); - //if (!jwtlife) - //{ - // apiResult.Code = "5000"; - // return BadRequest(apiResult); - //} + if (!jwtlife) + { + apiResult.Code = "5000"; + return BadRequest(apiResult); + } try { @@ -789,8 +791,25 @@ namespace FrontendWebApi.ApiControllers //發送文字簡訊並回傳狀態碼 retCode = this.SendMsg(input.Number, input.Msg); //取得messageID或文字描述 - retContent = this.Get_Message(); - apiResult.Data = retCode + " : " + retContent; + retContent = this.Get_Message(); //return id when sent message + apiResult.Data = retCode.ToString(); + Dictionary hiNetMsg = new Dictionary(); + if (retCode == 0) + hiNetMsg.Add("@MsgId", retContent); + else + hiNetMsg.Add("@ErrMessage", retCode + " : " + retContent); + + hiNetMsg.Add("@deleted", 0); + hiNetMsg.Add("@Number", input.Number); + hiNetMsg.Add("@Message", input.Msg); + hiNetMsg.Add("@status", retCode); + hiNetMsg.Add("@created_at", DateTime.Now); + hiNetMsg.Add("@created_by", myUser.userinfo_guid); + backendRepository.AddOneByCustomTableReturnId(hiNetMsg, "hinet_message"); + + //Thread.Sleep(5000); + //retCode = this.QueryMsg(retContent); + //retContent = this.Get_Message(); //return success status id(Successful:20230517103949") when querymsg status } else { From d03bf8bdb9f3ec6e9b68ba15ce7f25ecd87dbe4c Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 17 May 2023 14:25:24 +0800 Subject: [PATCH 4/6] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Services/Implement/webRequestService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index 17d6d47..f97d5df 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -234,9 +234,9 @@ namespace Backend.Services.Implement row.parent_path = stationName; //full_name 其實是點位名稱 point_name - row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault(); - if (conPoint.Where(x => x.name == tagName).FirstOrDefault() != null) - conPoint.Where(x => x.name == tagName).FirstOrDefault().isHistory = true; + row.full_name = conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).Select(x => x.displayName).FirstOrDefault(); + if (conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).FirstOrDefault() != null) + conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).FirstOrDefault().isHistory = true; row.isHistory = true; result.Add(row); @@ -263,9 +263,9 @@ namespace Backend.Services.Implement row.parent_path = stationName; //full_name 其實是點位名稱 point_name - row.full_name = conPoint.Where(x => x.name.Contains(tagName) && !x.isHistory).Select(x => x.displayName).FirstOrDefault(); - if (conPoint.Where(x => x.name.Contains(tagName) && !x.isHistory).FirstOrDefault() != null) - conPoint.Where(x => x.name.Contains(tagName) && !x.isHistory).FirstOrDefault().isHistory = true; + row.full_name = conPoint.Where(x => x.name.Contains(tagName.Replace('_', '/')) && !x.isHistory).Select(x => x.displayName).FirstOrDefault(); + if (conPoint.Where(x => x.name.Contains(tagName.Replace('_', '/')) && !x.isHistory).FirstOrDefault() != null) + conPoint.Where(x => x.name.Contains(tagName.Replace('_', '/')) && !x.isHistory).FirstOrDefault().isHistory = true; row.isHistory = true; result.Add(row); } From e7e26ef5f549c84c662b6b9aef5facee28f17da5 Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 17 May 2023 15:42:21 +0800 Subject: [PATCH 5/6] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BE=8C=E5=8F=B0=E5=90=8C=E6=AD=A5=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Services/Implement/webRequestService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index f97d5df..2528ae5 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -321,7 +321,7 @@ namespace Backend.Services.Implement } } - return result; + return result.Where(x => x.full_name != null).ToList(); } //private static void getRefData(string urlString, string encoded, List conPoint, List result, Welcome data ) //obixHistory data //{ From 3350dbc6f05cb5523003b56f4fed079e512b8c10 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 18 May 2023 12:44:43 +0800 Subject: [PATCH 6/6] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9ge?= =?UTF-8?q?t=20device=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/BuildController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index e0e91ec..5fa1457 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -532,6 +532,7 @@ namespace FrontendWebApi.ApiControllers left join device_master dm ON d.device_building_tag = dm.device_building_tag AND d.device_name_tag = dm.device_name_tag left join device_item di ON d.device_name_tag = di.device_name_tag + AND di.device_building_tag = '{post.building_tag}' AND di.deleted = 0 AND di.is_show_riserDiagram = 1 left join floor f on d.device_floor_tag = f.full_name and f.deleted = 0