diff --git a/Backend/Controllers/SystemCategoryController.cs b/Backend/Controllers/SystemCategoryController.cs index 3361f66..bf6d835 100644 --- a/Backend/Controllers/SystemCategoryController.cs +++ b/Backend/Controllers/SystemCategoryController.cs @@ -623,11 +623,17 @@ namespace Backend.Controllers try { var building_tag = await backendRepository.GetOneAsync($@"select system_value from variable where system_type = 'project_name' and deleted = 0"); - var sql = @"SELECT di.* + //var sql = @"SELECT di.* + // FROM device_item di + // JOIN variable sv ON di.device_name_tag = sv.system_value + // JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value + // WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag and di.is_link = 1"; + var sql = @"SELECT min(di.id), di.full_name, di.points, di.unit, di.is_show, di.is_show_riserDiagram, di.is_controll, di.is_bool, di.is_link, di.is_show_history, di.device_system_tag, di.device_name_tag FROM device_item di JOIN variable sv ON di.device_name_tag = sv.system_value JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value - WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag and di.is_link = 1"; + WHERE sv.id = 35 and di.deleted = 0 and di.is_link = 1 + group by di.full_name, di.points, di.unit, di.is_show, di.is_show_riserDiagram, di.is_controll, di.is_bool, di.is_link, di.is_show_history, di.device_system_tag, di.device_name_tag"; object param = new { Deleted = 0, id = id, building_tag = building_tag.Split("/")[1] }; diff --git a/Backend/Models/Parking.cs b/Backend/Models/Parking.cs index 018cd5a..21facfa 100644 --- a/Backend/Models/Parking.cs +++ b/Backend/Models/Parking.cs @@ -18,6 +18,8 @@ namespace Backend.Models public string ApiBase { get; set; } public string UserName { get; set; } public string Password { get; set; } + public string VendorId { get; set; } + public string VendorToken { get; set; } } public class SpaceResponse diff --git a/BackendWorkerService/Quartz/Jobs/ParkingJob.cs b/BackendWorkerService/Quartz/Jobs/ParkingJob.cs index 12df07e..653db61 100644 --- a/BackendWorkerService/Quartz/Jobs/ParkingJob.cs +++ b/BackendWorkerService/Quartz/Jobs/ParkingJob.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using NPOI.OpenXml4Net.OPC; using Quartz; using Repository.BackendRepository.Interface; using System; @@ -56,6 +57,8 @@ namespace BackendWorkerService.Quartz.Jobs parkingConfig.ApiBase = variable.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault(); parkingConfig.UserName = ed.AESDecrypt(variable.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault()); parkingConfig.Password = ed.AESDecrypt(variable.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault()); + parkingConfig.VendorId = variable.Where(x => x.Name == "X-VENDOR-ID").Select(x => x.Value).FirstOrDefault(); + parkingConfig.VendorToken = variable.Where(x => x.Name == "X-VENDOR-TOKEN").Select(x => x.Value).FirstOrDefault(); String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(parkingConfig.UserName + ":" + parkingConfig.Password)); @@ -68,6 +71,8 @@ namespace BackendWorkerService.Quartz.Jobs HttpWebRequest spaceRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/api/space/details"); spaceRequest.Method = "GET"; //request.Headers.Add("Authorization", "Basic " + encoded); + spaceRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId); + spaceRequest.Headers.Add("X-VENDOR-TOKEN", parkingConfig.VendorToken); spaceRequest.PreAuthenticate = true; spaceRequest.Timeout = System.Threading.Timeout.Infinite; spaceRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; @@ -192,6 +197,8 @@ namespace BackendWorkerService.Quartz.Jobs HttpWebRequest equipmentRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/api/equipment/state"); equipmentRequest.Method = "GET"; //request.Headers.Add("Authorization", "Basic " + encoded); + equipmentRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId); + equipmentRequest.Headers.Add("X-VENDOR-TOKEN", parkingConfig.VendorToken); equipmentRequest.PreAuthenticate = true; equipmentRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; diff --git a/BackendWorkerService/appsettings.Development.json b/BackendWorkerService/appsettings.Development.json index e822289..5c0ee01 100644 --- a/BackendWorkerService/appsettings.Development.json +++ b/BackendWorkerService/appsettings.Development.json @@ -26,7 +26,8 @@ //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut - "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 + //"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //ibms_dome_dome "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" }, diff --git a/BackendWorkerService/appsettings.json b/BackendWorkerService/appsettings.json index 8c853d2..771a64b 100644 --- a/BackendWorkerService/appsettings.json +++ b/BackendWorkerService/appsettings.json @@ -26,7 +26,8 @@ //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut - "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 + //"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //ibms_dome_dome "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" }, diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 0384ed3..f20749a 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -1140,11 +1140,15 @@ namespace Repository.BackendRepository.Implement string device_guid = device.Where(x => x.device_number == device_number).Select(x => x.device_guid).FirstOrDefault(); string device_system_tag = device.Where(x => x.device_number == device_number).Select(x => x.device_system_tag).FirstOrDefault(); string device_name_tag = device.Where(x => x.device_number == device_number).Select(x => x.device_name_tag).FirstOrDefault(); - sb.Append($@" - insert into device_disaster - (device_guid, device_system_value, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_serial_tag, device_number) - values ('{device_guid}', '{d.disasterValue}', '{device_number.Split('_')[0]}', '{device_system_tag}', '{device_name_tag}', '{device_number.Split('_')[2]}', - '{device_number.Split('_')[4]}', '{device_number}'); "); + var check = (await conn.QueryAsync($"select device_guid from device_disaster where device_guid = '{device_guid}' and device_system_value = '{d.disasterValue}'")).FirstOrDefault(); + if (string.IsNullOrEmpty(check)) + { + sb.Append($@" + insert into device_disaster + (device_guid, device_system_value, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_serial_tag, device_number) + values ('{device_guid}', '{d.disasterValue}', '{device_number.Split('_')[0]}', '{device_system_tag}', '{device_name_tag}', '{device_number.Split('_')[2]}', + '{device_number.Split('_')[4]}', '{device_number}'); "); + } } using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))