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