異常資料同步 debug
This commit is contained in:
parent
09fc3c9d9b
commit
1756d89e9f
@ -31,4 +31,11 @@ namespace solarApp.Model
|
|||||||
public string errDeviceBrand { get; set; }
|
public string errDeviceBrand { get; set; }
|
||||||
public string errDeviceModel { get; set; }
|
public string errDeviceModel { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class max_id
|
||||||
|
{
|
||||||
|
public int new_id { get; set; }
|
||||||
|
public int old_id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,9 +51,16 @@ namespace solarApp.Service
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 取得 昨天到今天的尚未同步的異常資料
|
#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
|
sql = $@" select * from alarmorion_orionalarmrecord
|
||||||
where id not in (select id from err_main )
|
where id > {ds_max[0].old_id}";
|
||||||
and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
|
// and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
|
||||||
//sql = $@"select * from err_main
|
//sql = $@"select * from err_main
|
||||||
// where site_id is null and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
|
// 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>();
|
var ds = conn.Query<errMain_model>(sql).AsList<errMain_model>();
|
||||||
@ -111,7 +118,7 @@ namespace solarApp.Service
|
|||||||
SUBSTRING_INDEX(SUBSTRING_INDEX(`value`, ':', -1) # : 後面所有string
|
SUBSTRING_INDEX(SUBSTRING_INDEX(`value`, ':', -1) # : 後面所有string
|
||||||
,'S', -1)
|
,'S', -1)
|
||||||
, 1, 9)
|
, 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);
|
rowCT = conn.Execute(sql);
|
||||||
duration = DateTime.Now - dt_start;
|
duration = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s3 errDevice", duration.TotalSeconds, "facetValue8", "err_main", "0", "", rowCT.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s3 errDevice", duration.TotalSeconds, "facetValue8", "err_main", "0", "", rowCT.ToString(), conn, null);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user