[BGService]修改緊急應變紀錄的相關邏輯

This commit is contained in:
張家睿 2024-08-30 16:51:10 +08:00
parent f2c56cc45d
commit 7fb85c72d7

View File

@ -88,7 +88,8 @@ namespace BackendWorkerService.Quartz.Jobs
foreach (var obj in filteredObjs) 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") var alarm_timestamp = obj.Descendants().Where(d => d.Name.LocalName == "abstime" && d.Attribute("name").Value == "timestamp")
.Select(d => .Select(d =>
{ {
@ -110,7 +111,7 @@ namespace BackendWorkerService.Quartz.Jobs
var dictionary = new Dictionary<string, object>() var dictionary = new Dictionary<string, object>()
{ {
{"@emergency_event_guid",newguid}, {"@emergency_event_guid",guid},
{"@disaster",filterDevice.device_system_value}, {"@disaster",filterDevice.device_system_value},
{"@building_tag", filterDevice.device_building_tag}, {"@building_tag", filterDevice.device_building_tag},
{"@device_guid",filterDevice.device_guid }, {"@device_guid",filterDevice.device_guid },
@ -120,7 +121,7 @@ namespace BackendWorkerService.Quartz.Jobs
dictionaryList.Add(dictionary); dictionaryList.Add(dictionary);
} }
// 之前以為沒有唯一識別碼(uuid)故該table有設置一個以device_guid跟alarm_time的unique替代
var mergeSql = @" var mergeSql = @"
INSERT INTO emergency_event INSERT INTO emergency_event
(emergency_event_guid, disaster, device_guid, building_tag, type, alarm_time) (emergency_event_guid, disaster, device_guid, building_tag, type, alarm_time)