From d2baf9b87b4acad796a4db7a80fa0aca0d22c3a8 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 6 Aug 2024 13:35:11 +0800 Subject: [PATCH] =?UTF-8?q?[ALL]=E6=AD=B7=E5=8F=B2=E8=B3=87=E6=96=99?= =?UTF-8?q?=E5=91=88=E7=8F=BE=E9=BB=9E=E4=BD=8D=E6=94=B9=E6=88=90=E6=A0=B9?= =?UTF-8?q?=E6=93=9Adevice=5Fnumber=E8=80=8C=E9=9D=9E=E5=B0=8F=E9=A1=9E?= =?UTF-8?q?=EF=BC=8C=E9=80=A3=E5=B8=B6=E6=96=B0=E5=A2=9Edevice=5Fnumber?= =?UTF-8?q?=E6=AC=84=E4=BD=8D=E9=80=B2import=5Fniagara=5Fitem=5Fhistory?= =?UTF-8?q?=E5=8E=BB=E5=81=9A=E5=B0=8D=E6=87=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Services/Implement/webRequestService.cs | 3 +++ FrontendWebApi/ApiControllers/HistoryController.cs | 2 ++ .../Implement/NiagaraDataSynchronizeRepository.cs | 4 +++- Repository/Models/BackgroundServiceTask.cs | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index 259864b..3730e72 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -607,6 +607,9 @@ namespace Backend.Services.Implement else if (tagName.Split('_').Length == 6) { //巨蛋 tag 5 段版本 ImpNiaItem row = new ImpNiaItem(); + int index = tagName.LastIndexOf('_'); + string device = (index != -1) ? tagName.Substring(0, index) : tagName; + row.device_number = device; // 2024.08.01 新增 為了解決不同小類下的設備有不同點位的問題 if (tagName.Split('_')[1] == "S" || tagName.Split('_')[1] == "B" || tagName.Split('_')[1] == "CWB") //for security system { row.device_building_tag = tagName.Split('_')[0]; diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index f5e6ef7..143ee8f 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -593,6 +593,7 @@ namespace FrontendWebApi.ApiControllers and b.device_building_tag COLLATE utf8mb4_unicode_ci = a.device_building_tag and b.device_name_tag COLLATE utf8mb4_unicode_ci = a.device_name_tag join building c on c.building_tag = a.device_building_tag + join import_niagara_item_history h on a.device_number = h.device_number join variable v1 on v1.system_value = a.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' join variable v2 on v2.system_value = a.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0 and b.is_link = 1 and b.is_show_history = 1 @@ -635,6 +636,7 @@ namespace FrontendWebApi.ApiControllers and a.device_building_tag COLLATE utf8mb4_unicode_ci = b.device_building_tag and a.device_name_tag COLLATE utf8mb4_unicode_ci = b.device_name_tag join building c on c.building_tag = b.device_building_tag + join import_niagara_item_history h on b.device_number = h.device_number and a.points = h.device_point_name join variable v1 on v1.system_value = b.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' join variable v2 on v2.system_value = b.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3' where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0 diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index cc26c53..bbff6fa 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -1803,6 +1803,7 @@ SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS `import_niagara_item_history`; CREATE TABLE `import_niagara_item_history` ( `id` int(11) NOT NULL AUTO_INCREMENT, +`device_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '完整 TagName 設備編號', `device_area_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, `device_building_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, `device_system_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, @@ -1847,11 +1848,12 @@ SET FOREIGN_KEY_CHECKS = 1;"; { if (count == 0) { - ss = @"insert import_niagara_item_history(device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_master_tag, + ss = @"insert import_niagara_item_history(device_number,device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, device_point_name, parent_path, full_name, is_history, created_at) values"; } ss += $@" ('" + + row.device_number + "', '" + row.device_area_tag + "', '" + row.device_building_tag + "', '" + row.device_system_tag + "', '" + diff --git a/Repository/Models/BackgroundServiceTask.cs b/Repository/Models/BackgroundServiceTask.cs index b321f67..b0f1f19 100644 --- a/Repository/Models/BackgroundServiceTask.cs +++ b/Repository/Models/BackgroundServiceTask.cs @@ -123,6 +123,7 @@ namespace Repository.Models public class ImpNiaItem { + public string device_number { get; set; } public string device_area_tag { get; set; } public string device_building_tag { get; set; } public string device_system_tag { get; set; }