From 1756d89e9f3743481c466c82029ff449f4c52316 Mon Sep 17 00:00:00 2001 From: cesar liu Date: Thu, 18 Aug 2022 23:48:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=B0=E5=B8=B8=E8=B3=87=E6=96=99=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Model/errMain_model.cs | 7 +++++++ solarApp/Service/procSyncError.cs | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/solarApp/Model/errMain_model.cs b/solarApp/Model/errMain_model.cs index 548436a..2b33f28 100644 --- a/solarApp/Model/errMain_model.cs +++ b/solarApp/Model/errMain_model.cs @@ -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; } + } + } diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs index bfd5bab..0e1bba5 100644 --- a/solarApp/Service/procSyncError.cs +++ b/solarApp/Service/procSyncError.cs @@ -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(sql).AsList(); + + 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(sql).AsList(); @@ -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);