異常資料同步 debug

This commit is contained in:
cesar liu 2022-08-18 23:48:35 +08:00
parent 09fc3c9d9b
commit 1756d89e9f
2 changed files with 17 additions and 3 deletions

View File

@ -31,4 +31,11 @@ namespace solarApp.Model
public string errDeviceBrand { get; set; }
public string errDeviceModel { get; set; }
}
public class max_id
{
public int new_id { get; set; }
public int old_id { get; set; }
}
}

View File

@ -51,9 +51,16 @@ namespace solarApp.Service
#endregion
#region
sql = $@" select max(id) new_id, (select max(id) old_id from err_main ) old_id
from alarmorion_orionalarmrecord ";
var ds_max = conn.Query<max_id>(sql).AsList<max_id>();
if (ds_max.Count == 0 ) return false; // 查無資料
if (ds_max[0].new_id == ds_max[0].old_id) return true; // 無新資料
sql = $@" select * from alarmorion_orionalarmrecord
where id not in (select id from err_main )
and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
where id > {ds_max[0].old_id}";
// and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
//sql = $@"select * from err_main
// where site_id is null and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
var ds = conn.Query<errMain_model>(sql).AsList<errMain_model>();
@ -111,7 +118,7 @@ namespace solarApp.Service
SUBSTRING_INDEX(SUBSTRING_INDEX(`value`, ':', -1) # : string
,'S', -1)
, 1, 9)
where facetName = 8 and errDevice is null and a.datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}';";
where facetName = 8 and a.site_id is null and a.datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}';";
rowCT = conn.Execute(sql);
duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s3 errDevice", duration.TotalSeconds, "facetValue8", "err_main", "0", "", rowCT.ToString(), conn, null);