diff --git a/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs b/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs index db01740..b06eb72 100644 --- a/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs +++ b/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs @@ -88,7 +88,8 @@ namespace BackendWorkerService.Quartz.Jobs foreach (var obj in filteredObjs) { - var newguid = Guid.NewGuid(); + var guid = obj.Descendants().Where(d => d.Name.LocalName == "str" && d.Attribute("name").Value == "niagara-uuid"). + Select(x => x.Attribute("val").Value).FirstOrDefault(); var alarm_timestamp = obj.Descendants().Where(d => d.Name.LocalName == "abstime" && d.Attribute("name").Value == "timestamp") .Select(d => { @@ -110,7 +111,7 @@ namespace BackendWorkerService.Quartz.Jobs var dictionary = new Dictionary() { - {"@emergency_event_guid",newguid}, + {"@emergency_event_guid",guid}, {"@disaster",filterDevice.device_system_value}, {"@building_tag", filterDevice.device_building_tag}, {"@device_guid",filterDevice.device_guid }, @@ -120,7 +121,7 @@ namespace BackendWorkerService.Quartz.Jobs dictionaryList.Add(dictionary); } - + // 之前以為沒有唯一識別碼(uuid),故該table有設置一個以device_guid跟alarm_time的unique替代 var mergeSql = @" INSERT INTO emergency_event (emergency_event_guid, disaster, device_guid, building_tag, type, alarm_time)