diff --git a/solarApp/Service/procInvSvc.cs b/solarApp/Service/procInvSvc.cs index 29f8ebe..649af35 100644 --- a/solarApp/Service/procInvSvc.cs +++ b/solarApp/Service/procInvSvc.cs @@ -576,19 +576,25 @@ namespace solarApp.Service using (MySqlConnection conn = new MySqlConnection(Connection1)) { conn.Open(); + MySqlCommand cmd = new MySqlCommand(); + cmd.Connection = conn; + cmd.CommandTimeout = 720; + DateTime dt_start = DateTime.Now; + arclog.insert_log(_powerStationID, "report_day step > 開始執行", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 開始執行", conn, cmd); string sql = @$"delete from report_invday where powerstationid = {_powerStationID} and left(report_date, 10) = '{_date1}'"; conn.Execute(sql); - DateTime dt_start = DateTime.Now; + arclog.insert_log(_powerStationID, "report_day step > 刪除 report_invday", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 刪除 report_invday", conn, cmd); + #region get SQL //try //{ - if (_logger != null) + if (_logger != null) { _logger.LogInformation("【Proc_inv_日報 】開始執行[{0}]在{1}inv_get_SQLStatement", _siteID, _date1); } - - #region 建立 temp table - sql = @$"DROP TABLE IF EXISTS temp_invDay{_powerStationID}_s1; + arclog.insert_log(_powerStationID, "report_day step > table 開始建立", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 開始建立table", conn, cmd); + #region 建立 temp table + sql = @$"DROP TABLE IF EXISTS temp_invDay{_powerStationID}_s1; CREATE TABLE temp_invDay{_powerStationID}_s1 select a.`TIMESTAMP` report_date, a.powerstationId, a.INVERTERID, a.kwh , round(TODAYKWH, 6) TODAYKWH, round(KWHKWP, 6) KWHKWP, round(PR, 6) PR @@ -597,13 +603,13 @@ CREATE TABLE temp_invDay{_powerStationID}_s1 # 2. add index ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_date, inverterid);"; //conn.Execute(ss); - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = conn; - cmd.CommandTimeout = 720; + + arclog.insert_log(_powerStationID, "report_day step > table 建立完成", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 建立table完成", conn, cmd); - try - { - cmd.CommandText = sql; + try + { + arclog.insert_log(_powerStationID, "report_day step try", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "start 日報 try", conn, cmd); + cmd.CommandText = sql; cmd.ExecuteNonQuery(); cmd.CommandText = @$"select count(*) ct from temp_invDay{_powerStationID}_s1";