異常同步 SQL 語法執行時間延長
This commit is contained in:
parent
c5b18933c4
commit
452f43aeaf
@ -44,7 +44,7 @@ namespace solarApp.Service
|
|||||||
a.`acktime` = b.`acktime`,
|
a.`acktime` = b.`acktime`,
|
||||||
a.`lastupdate` = b.`lastupdate`
|
a.`lastupdate` = b.`lastupdate`
|
||||||
where a.sourcestate = 1 and b.datestamp >= '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}'";// and a.site_id is not null "; // ;";
|
where a.sourcestate = 1 and b.datestamp >= '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}'";// and a.site_id is not null "; // ;";
|
||||||
int rowCount = conn.Execute(sql);
|
int rowCount = conn.Execute(sql, commandTimeout: 600);
|
||||||
TimeSpan durationSec = DateTime.Now - dt_start;
|
TimeSpan durationSec = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s0 normaltime", durationSec.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCount.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s0 normaltime", durationSec.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCount.ToString(), conn, null);
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ namespace solarApp.Service
|
|||||||
#region 取得 昨天到今天的尚未同步的異常資料
|
#region 取得 昨天到今天的尚未同步的異常資料
|
||||||
sql = $@" select max(id) new_id, (select max(id) old_id from err_main ) old_id
|
sql = $@" select max(id) new_id, (select max(id) old_id from err_main ) old_id
|
||||||
from alarmorion_orionalarmrecord ";
|
from alarmorion_orionalarmrecord ";
|
||||||
var ds_max = conn.Query<max_id>(sql).AsList<max_id>();
|
var ds_max = conn.Query<max_id>(sql, commandTimeout: 600).AsList<max_id>();
|
||||||
|
|
||||||
if (ds_max.Count == 0 ) return false; // 查無資料
|
if (ds_max.Count == 0 ) return false; // 查無資料
|
||||||
if (ds_max[0].new_id == ds_max[0].old_id) return true; // 無新資料
|
if (ds_max[0].new_id == ds_max[0].old_id) return true; // 無新資料
|
||||||
@ -63,7 +63,7 @@ namespace solarApp.Service
|
|||||||
// 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, commandTimeout: 600).AsList<errMain_model>();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
bool isfirst = true;
|
bool isfirst = true;
|
||||||
foreach (var item in ds)
|
foreach (var item in ds)
|
||||||
@ -89,7 +89,7 @@ namespace solarApp.Service
|
|||||||
, {item.isOpen}, {item.sourceState}, {item.ackState}, {item.ackRequired}, {item.alarmClass}, {item.priority}, {item.normalTime}, {item.ackTime}
|
, {item.isOpen}, {item.sourceState}, {item.ackState}, {item.ackRequired}, {item.alarmClass}, {item.priority}, {item.normalTime}, {item.ackTime}
|
||||||
, '{item.userAccount}', {item.alarmTransition}, {item.lastUpdate}); ";
|
, '{item.userAccount}', {item.alarmTransition}, {item.lastUpdate}); ";
|
||||||
}
|
}
|
||||||
int rowCT = conn.Execute(sql);
|
int rowCT = conn.Execute(sql, commandTimeout: 600);
|
||||||
TimeSpan duration = DateTime.Now - dt_start;
|
TimeSpan duration = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s1", duration.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCT.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s1", duration.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCT.ToString(), conn, null);
|
||||||
#endregion
|
#endregion
|
||||||
@ -102,7 +102,7 @@ namespace solarApp.Service
|
|||||||
SUBSTRING_INDEX(`value`, '@', 1) # @前面所有string --> e:7
|
SUBSTRING_INDEX(`value`, '@', 1) # @前面所有string --> e:7
|
||||||
, ':', -1)
|
, ':', -1)
|
||||||
where facetName = 4 and alarm in ({sb.ToString()});";
|
where facetName = 4 and alarm in ({sb.ToString()});";
|
||||||
rowCT = conn.Execute(sql);
|
rowCT = conn.Execute(sql, commandTimeout: 600);
|
||||||
duration = DateTime.Now - dt_start;
|
duration = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s2 errValue", duration.TotalSeconds, "facetvalue4", "err_main", "0", "", rowCT.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s2 errValue", duration.TotalSeconds, "facetvalue4", "err_main", "0", "", rowCT.ToString(), conn, null);
|
||||||
#endregion
|
#endregion
|
||||||
@ -119,7 +119,7 @@ namespace solarApp.Service
|
|||||||
,'S', -1)
|
,'S', -1)
|
||||||
, 1, 9)
|
, 1, 9)
|
||||||
where facetName = 8 and a.site_id 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, commandTimeout: 600);
|
||||||
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);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ namespace solarApp.Service
|
|||||||
errDeviceBrand = b.brand,
|
errDeviceBrand = b.brand,
|
||||||
errDeviceModel = b.Model
|
errDeviceModel = b.Model
|
||||||
where errDevice is not null and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}';";
|
where errDevice is not null and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}';";
|
||||||
rowCT = conn.Execute(sql);
|
rowCT = conn.Execute(sql, commandTimeout: 600);
|
||||||
duration = DateTime.Now - dt_start;
|
duration = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s4 site_id", duration.TotalSeconds, "v_company_inv", "err_main", "0", "", rowCT.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s4 site_id", duration.TotalSeconds, "v_company_inv", "err_main", "0", "", rowCT.ToString(), conn, null);
|
||||||
#endregion
|
#endregion
|
||||||
@ -155,13 +155,13 @@ namespace solarApp.Service
|
|||||||
) x
|
) x
|
||||||
)z join v_station v on z.site_id = v.siteid
|
)z join v_station v on z.site_id = v.siteid
|
||||||
where row_num = 1;";
|
where row_num = 1;";
|
||||||
conn.Execute(sql);
|
conn.Execute(sql, commandTimeout: 600);
|
||||||
|
|
||||||
|
|
||||||
sql = $@"update power_station set healthstatus = 1;
|
sql = $@"update power_station set healthstatus = 1;
|
||||||
update power_station a join temp_healthstatus b on a.code = b.site_id
|
update power_station a join temp_healthstatus b on a.code = b.site_id
|
||||||
set a.healthstatus = b.healthstatus;";
|
set a.healthstatus = b.healthstatus;";
|
||||||
rowCT = conn.Execute(sql);
|
rowCT = conn.Execute(sql, commandTimeout: 600);
|
||||||
duration = DateTime.Now - dt_start;
|
duration = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s5 site health", duration.TotalSeconds, "temp_healthstatus", "err_main", "0", "", rowCT.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s5 site health", duration.TotalSeconds, "temp_healthstatus", "err_main", "0", "", rowCT.ToString(), conn, null);
|
||||||
|
|
||||||
@ -178,11 +178,11 @@ namespace solarApp.Service
|
|||||||
group by errDevice
|
group by errDevice
|
||||||
)b on a.inverterid = b.errDevice
|
)b on a.inverterid = b.errDevice
|
||||||
set status = errStatus;";
|
set status = errStatus;";
|
||||||
rowCT = conn.Execute(sql);
|
rowCT = conn.Execute(sql, commandTimeout: 600);
|
||||||
duration = DateTime.Now - dt_start;
|
duration = DateTime.Now - dt_start;
|
||||||
arclog.insert_log("0", "syncError s6 inv health", duration.TotalSeconds, "", "err_main", "0", "", rowCT.ToString(), conn, null);
|
arclog.insert_log("0", "syncError s6 inv health", duration.TotalSeconds, "", "err_main", "0", "", rowCT.ToString(), conn, null);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
2
solarApp/fmArchive.Designer.cs
generated
2
solarApp/fmArchive.Designer.cs
generated
@ -753,7 +753,7 @@ namespace solarApp
|
|||||||
//
|
//
|
||||||
// timer1
|
// timer1
|
||||||
//
|
//
|
||||||
this.timer1.Interval = 1000;
|
this.timer1.Interval = 10000;
|
||||||
//
|
//
|
||||||
// fmArchive
|
// fmArchive
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user