[后台] 修改niagara 同步device_item 同步is_link, is_history 值

This commit is contained in:
dev02 2023-06-02 18:02:11 +08:00
parent 371e80eb89
commit 6458a10215
2 changed files with 25 additions and 11 deletions

View File

@ -170,12 +170,12 @@ namespace Backend
);
#endregion
#region API
services.AddSingleton<WeatherAPIJob>();
services.AddSingleton(
new JobSchedule(jobType: typeof(WeatherAPIJob), cronExpression: Configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob"))
);
#endregion
//#region 定時取得氣象API
//services.AddSingleton<WeatherAPIJob>();
//services.AddSingleton(
//new JobSchedule(jobType: typeof(WeatherAPIJob), cronExpression: Configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob"))
//);
//#endregion
double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute");
services.AddSession(options =>

View File

@ -506,11 +506,25 @@ namespace Repository.BackendRepository.Implement
//本次有匯入的 isLink 改為 1, 沒有的 isLink = 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE device_item d LEFT JOIN import_niagara_item m
ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name and d.full_name = m.full_name and d.is_show_history = m.is_history
SET d.is_link = case when device_point_name is null then 0 else 1 end ,
d.is_show_history = case when device_point_name is null then 0 else 1 end
where m.is_history = 1
update
device_item d
LEFT JOIN import_niagara_item m
ON d.device_system_tag = m.device_system_tag
and d.device_name_tag = m.device_name_tag
and d.points = m.device_point_name
and d.full_name = m.full_name
SET d.is_link = case when device_point_name is null then 0 else 1 end;
update
device_item d
LEFT JOIN import_niagara_item m
ON d.device_system_tag = m.device_system_tag
and d.device_name_tag = m.device_name_tag
and d.points = m.device_point_name
and d.full_name = m.full_name
and d.is_show_history = m.is_history
SET d.is_show_history = case when device_point_name is null then 0 else 1 end
where (m.is_history = 1 or d.is_show_history);
");
await conn.ExecuteAsync(sb.ToString());