debug: 歸檔調整
This commit is contained in:
parent
02e0245c92
commit
c0a7a2a7dc
@ -42,8 +42,8 @@ namespace solarApp.Service
|
||||
// string yyyymm = System.DateTime.Now.AddMonths(-2).ToString("yyyy-MM");
|
||||
_siteID = siteID;
|
||||
//搬移的月份
|
||||
move_month = System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM");
|
||||
//move_month = System.DateTime.Now.ToString("yyyy-MM"); //這個月
|
||||
move_month = System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM")+ "--01";
|
||||
// move_month = System.DateTime.Now.ToString("yyyy-MM") + "--01"; //這個月
|
||||
//_date1 = date1;
|
||||
get_siteInfo();
|
||||
checkTable();
|
||||
@ -361,7 +361,8 @@ namespace solarApp.Service
|
||||
// System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】開始執行[{_siteDB}.s{_siteID}_inv]的資料表向[{_siteDB}_history.s{_siteID}_inv]搬移");
|
||||
string for_insert_inv = $@"INSERT {_siteDB}_history.s{_siteID01}_inv(`ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `INVERTERID`, `SN`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `ACRUNTIME`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `DCRUNTIME`, `WH`, `TODAYKWH`, `TOTALKWH`, `PR`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `CrdTime`)
|
||||
SELECT `ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `INVERTERID`, `SN`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `ACRUNTIME`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `DCRUNTIME`, `WH`, `TODAYKWH`, `TOTALKWH`, `PR`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `CrdTime` FROM {_siteDB}.s{_siteID01}_inv
|
||||
WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '{move_month}'";
|
||||
//WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
int rowCT = conn.Execute(for_insert_inv, commandTimeout: 6000);
|
||||
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】{_siteDB}.s{_siteID}_inv的七月前資料寫入至{_siteDB}_history.s{_siteID}_inv【寫入成功】於{dateTime}");
|
||||
// log
|
||||
@ -371,7 +372,8 @@ namespace solarApp.Service
|
||||
dt_start1 = DateTime.Now;
|
||||
|
||||
string for_delete_inv = $@"DELETE FROM {_siteDB}.s{_siteID01}_inv
|
||||
WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '{move_month}'";
|
||||
//WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
rowCT = conn.Execute(for_delete_inv, commandTimeout: 6000);
|
||||
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】{_siteDB}.s{_siteID}_sensoravg搬移至{_siteDB}_history.s{_siteID}_sensoravg【搬移資料成功】於{dateTime} 共 {delete_inv.ToString()} 筆");
|
||||
duration = DateTime.Now - dt_start1;
|
||||
@ -407,14 +409,17 @@ namespace solarApp.Service
|
||||
string for_insert_sensoravg = $@"INSERT {_siteDB}_history.s{_siteID01}_sensoravg(`ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `SENSORAVG01`, `SENSORAVG02`, `SENSORAVG03`, `SENSORAVG04`, `SENSORAVG05`, `SENSORAVG06`, `SENSORAVG07`, `SENSORAVG08`, `SENSORAVG09`, `SENSORAVG10`, `SENSORAVG11`, `SENSORAVG12`, `SENSORAVG13`, `SENSORAVG14`, `SENSORAVG15`, `SENSORAVG16`, `SENSORAVG17`, `SENSORAVG18`, `SENSORAVG19`, `SENSORAVG20`, `SENSORAVG21`, `SENSORAVG22`, `SENSORAVG23`, `SENSORAVG24`, `SENSORAVG25`, `SENSORAVG26`, `SENSORAVG27`, `SENSORAVG28`, `SENSORAVG29`, `SENSORAVG30`, `SENSORAVG31`, `SENSORAVG32`, `SENSORAVG33`, `SENSORAVG34`, `SENSORAVG35`, `SENSORAVG36`, `SENSORAVG37`, `SENSORAVG38`, `SENSORAVG39`, `SENSORAVG40`, `SENSORAVG41`, `SENSORAVG42`, `SENSORAVG43`, `SENSORAVG44`, `SENSORAVG45`, `SENSORAVG46`, `SENSORAVG47`, `SENSORAVG48`, `SENSORAVG49`, `SENSORAVG50`, `CrdTime`)
|
||||
SELECT `ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `SENSORAVG01`, `SENSORAVG02`, `SENSORAVG03`, `SENSORAVG04`, `SENSORAVG05`, `SENSORAVG06`, `SENSORAVG07`, `SENSORAVG08`, `SENSORAVG09`, `SENSORAVG10`, `SENSORAVG11`, `SENSORAVG12`, `SENSORAVG13`, `SENSORAVG14`, `SENSORAVG15`, `SENSORAVG16`, `SENSORAVG17`, `SENSORAVG18`, `SENSORAVG19`, `SENSORAVG20`, `SENSORAVG21`, `SENSORAVG22`, `SENSORAVG23`, `SENSORAVG24`, `SENSORAVG25`, `SENSORAVG26`, `SENSORAVG27`, `SENSORAVG28`, `SENSORAVG29`, `SENSORAVG30`, `SENSORAVG31`, `SENSORAVG32`, `SENSORAVG33`, `SENSORAVG34`, `SENSORAVG35`, `SENSORAVG36`, `SENSORAVG37`, `SENSORAVG38`, `SENSORAVG39`, `SENSORAVG40`, `SENSORAVG41`, `SENSORAVG42`, `SENSORAVG43`, `SENSORAVG44`, `SENSORAVG45`, `SENSORAVG46`, `SENSORAVG47`, `SENSORAVG48`, `SENSORAVG49`, `SENSORAVG50`, `CrdTime`
|
||||
FROM {_siteDB}.s{_siteID01}_sensoravg
|
||||
WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '{move_month}'";
|
||||
// WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
int rowCT = conn.Execute(for_insert_sensoravg, commandTimeout: 600);
|
||||
// log
|
||||
TimeSpan duration = DateTime.Now - dt_start1;
|
||||
arclog.insert_log(_powerStationID, @$"move raw s1 - {move_month}", duration.TotalSeconds, $"{_siteDB}.s{_siteID01}_sensoravg", $"{_siteDB}_history.s{_siteID01}_sensoravg", "0", "", rowCT.ToString(), conn, null);
|
||||
dt_start1 = DateTime.Now;
|
||||
|
||||
string for_delete_sensoravg = $@"DELETE FROM {_siteDB}.s{_siteID01}_sensoravg WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
string for_delete_sensoravg = $@"DELETE FROM {_siteDB}.s{_siteID01}_sensoravg
|
||||
WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '{move_month}'";
|
||||
// WHERE LEFT(crdTime, 7) < '{move_month}'";
|
||||
rowCT = conn.Execute(for_delete_sensoravg, commandTimeout: 600);
|
||||
|
||||
duration = DateTime.Now - dt_start1;
|
||||
|
||||
@ -259,7 +259,7 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
arclog.insert_log(_powerStationID, "step1 insert inverter_15min history", 0, "inverter_history_15min", "insert inverter_15min history", "0", "", "", conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "step1 insert inverter_15min history " + _date1, 0, "inverter_history_15min", "insert inverter_15min history", "1", "", "", conn, cmd);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -338,7 +338,7 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
arclog.insert_log(_powerStationID, "inverter_history_hour step1 ", 0, "inverter_history_hour", "insert inverter_history_hour error", "0", "", "", conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "inverter_history_hour step1 " + _date1, 0, "inverter_history_hour", "insert inverter_history_hour error", "0", "", "", conn, cmd);
|
||||
// throw ex;
|
||||
}
|
||||
|
||||
|
||||
35
solarApp/fmArchive.Designer.cs
generated
35
solarApp/fmArchive.Designer.cs
generated
@ -35,6 +35,7 @@ namespace solarApp
|
||||
tabControl1 = new System.Windows.Forms.TabControl();
|
||||
tabPage1 = new System.Windows.Forms.TabPage();
|
||||
splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
bt_procStep2 = new System.Windows.Forms.Button();
|
||||
button3 = new System.Windows.Forms.Button();
|
||||
label2 = new System.Windows.Forms.Label();
|
||||
textBox1 = new System.Windows.Forms.TextBox();
|
||||
@ -118,7 +119,7 @@ namespace solarApp
|
||||
tabControl1.Location = new System.Drawing.Point(0, 0);
|
||||
tabControl1.Name = "tabControl1";
|
||||
tabControl1.SelectedIndex = 0;
|
||||
tabControl1.Size = new System.Drawing.Size(1782, 953);
|
||||
tabControl1.Size = new System.Drawing.Size(1782, 1026);
|
||||
tabControl1.TabIndex = 0;
|
||||
//
|
||||
// tabPage1
|
||||
@ -128,7 +129,7 @@ namespace solarApp
|
||||
tabPage1.Location = new System.Drawing.Point(4, 49);
|
||||
tabPage1.Name = "tabPage1";
|
||||
tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage1.Size = new System.Drawing.Size(1774, 900);
|
||||
tabPage1.Size = new System.Drawing.Size(1774, 973);
|
||||
tabPage1.TabIndex = 0;
|
||||
tabPage1.Text = " 歸檔 ";
|
||||
tabPage1.UseVisualStyleBackColor = true;
|
||||
@ -142,6 +143,7 @@ namespace solarApp
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
|
||||
splitContainer1.Panel1.Controls.Add(bt_procStep2);
|
||||
splitContainer1.Panel1.Controls.Add(button3);
|
||||
splitContainer1.Panel1.Controls.Add(label2);
|
||||
splitContainer1.Panel1.Controls.Add(textBox1);
|
||||
@ -169,11 +171,21 @@ namespace solarApp
|
||||
splitContainer1.Panel2.Controls.Add(gv_inv_detail);
|
||||
splitContainer1.Panel2.Controls.Add(gv_rpt_invDay);
|
||||
splitContainer1.Panel2.Controls.Add(panel1);
|
||||
splitContainer1.Size = new System.Drawing.Size(1768, 894);
|
||||
splitContainer1.Size = new System.Drawing.Size(1768, 967);
|
||||
splitContainer1.SplitterDistance = 400;
|
||||
splitContainer1.SplitterWidth = 10;
|
||||
splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// bt_procStep2
|
||||
//
|
||||
bt_procStep2.Location = new System.Drawing.Point(109, 910);
|
||||
bt_procStep2.Name = "bt_procStep2";
|
||||
bt_procStep2.Size = new System.Drawing.Size(166, 57);
|
||||
bt_procStep2.TabIndex = 21;
|
||||
bt_procStep2.Text = "單跑報告";
|
||||
bt_procStep2.UseVisualStyleBackColor = true;
|
||||
bt_procStep2.Click += bt_procStep2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
@ -403,7 +415,7 @@ namespace solarApp
|
||||
gv_inv_detail.ReadOnly = true;
|
||||
gv_inv_detail.RowHeadersWidth = 51;
|
||||
gv_inv_detail.RowTemplate.Height = 29;
|
||||
gv_inv_detail.Size = new System.Drawing.Size(590, 819);
|
||||
gv_inv_detail.Size = new System.Drawing.Size(590, 892);
|
||||
gv_inv_detail.TabIndex = 2;
|
||||
gv_inv_detail.CellDoubleClick += gv_inv_detail_CellDoubleClick;
|
||||
//
|
||||
@ -420,7 +432,7 @@ namespace solarApp
|
||||
gv_rpt_invDay.ReadOnly = true;
|
||||
gv_rpt_invDay.RowHeadersWidth = 51;
|
||||
gv_rpt_invDay.RowTemplate.Height = 29;
|
||||
gv_rpt_invDay.Size = new System.Drawing.Size(768, 819);
|
||||
gv_rpt_invDay.Size = new System.Drawing.Size(768, 892);
|
||||
gv_rpt_invDay.TabIndex = 1;
|
||||
gv_rpt_invDay.CellFormatting += gv_rpt_invDay_CellFormatting;
|
||||
gv_rpt_invDay.CellMouseDoubleClick += gv_rpt_invDay_CellMouseDoubleClick;
|
||||
@ -532,7 +544,7 @@ namespace solarApp
|
||||
tabPage5.Location = new System.Drawing.Point(4, 49);
|
||||
tabPage5.Name = "tabPage5";
|
||||
tabPage5.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage5.Size = new System.Drawing.Size(1774, 900);
|
||||
tabPage5.Size = new System.Drawing.Size(1774, 973);
|
||||
tabPage5.TabIndex = 4;
|
||||
tabPage5.Text = "資料查詢";
|
||||
tabPage5.UseVisualStyleBackColor = true;
|
||||
@ -543,7 +555,7 @@ namespace solarApp
|
||||
tabPage2.Location = new System.Drawing.Point(4, 49);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage2.Size = new System.Drawing.Size(1774, 900);
|
||||
tabPage2.Size = new System.Drawing.Size(1774, 973);
|
||||
tabPage2.TabIndex = 1;
|
||||
tabPage2.Text = "email 測試";
|
||||
tabPage2.UseVisualStyleBackColor = true;
|
||||
@ -565,7 +577,7 @@ namespace solarApp
|
||||
//
|
||||
splitContainer2.Panel2.Controls.Add(richTextBox1);
|
||||
splitContainer2.Panel2.Controls.Add(panel2);
|
||||
splitContainer2.Size = new System.Drawing.Size(1768, 894);
|
||||
splitContainer2.Size = new System.Drawing.Size(1768, 967);
|
||||
splitContainer2.SplitterDistance = 299;
|
||||
splitContainer2.SplitterWidth = 10;
|
||||
splitContainer2.TabIndex = 1;
|
||||
@ -585,7 +597,7 @@ namespace solarApp
|
||||
richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
richTextBox1.Location = new System.Drawing.Point(0, 321);
|
||||
richTextBox1.Name = "richTextBox1";
|
||||
richTextBox1.Size = new System.Drawing.Size(1459, 573);
|
||||
richTextBox1.Size = new System.Drawing.Size(1459, 646);
|
||||
richTextBox1.TabIndex = 1;
|
||||
richTextBox1.Text = "";
|
||||
//
|
||||
@ -757,10 +769,10 @@ namespace solarApp
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(1782, 953);
|
||||
ClientSize = new System.Drawing.Size(1782, 1026);
|
||||
Controls.Add(tabControl1);
|
||||
Name = "fmArchive";
|
||||
Text = "fmArchive 08-29";
|
||||
Text = "fmArchive 0918";
|
||||
Load += fmArchive_Load;
|
||||
tabControl1.ResumeLayout(false);
|
||||
tabPage1.ResumeLayout(false);
|
||||
@ -845,5 +857,6 @@ namespace solarApp
|
||||
private System.Windows.Forms.TabPage tabPage5;
|
||||
private System.Windows.Forms.Button btSyncErr;
|
||||
private System.Windows.Forms.Button bt_MoveRawData;
|
||||
private System.Windows.Forms.Button bt_procStep2;
|
||||
}
|
||||
}
|
||||
@ -850,6 +850,45 @@ namespace solarApp
|
||||
lbMsgTitle.Text = System.DateTime.Now.ToString() + " 水位管理 - 資料搬移完成!";
|
||||
}
|
||||
|
||||
private void bt_procStep2_Click(object sender, EventArgs e)
|
||||
{
|
||||
var site_list = stationSvc.get_station_list32(false); // 不含 32
|
||||
//var site_list = stationSvc.get_station_list32(true); // 不含 32
|
||||
|
||||
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
||||
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
|
||||
procSensorSvc sensorSvc = new procSensorSvc();
|
||||
procInvSvc invSvc = new procInvSvc();
|
||||
procStationSvc siteSvc = new procStationSvc();
|
||||
sensorSvc.isFirst = true;
|
||||
foreach (var item in site_list)
|
||||
{
|
||||
//for sensor_history_hour
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
sensorSvc.isFirst = false;
|
||||
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
}
|
||||
|
||||
//單獨製作 32
|
||||
site_list = stationSvc.get_station_list32(true); // 不含 32
|
||||
sensorSvc.isFirst = true;
|
||||
foreach (var item in site_list)
|
||||
{
|
||||
//for sensor_history_hour
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
sensorSvc.isFirst = false;
|
||||
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
}
|
||||
|
||||
lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!";
|
||||
}
|
||||
|
||||
//test for email format
|
||||
//private void button3_Click(object sender, EventArgs e)
|
||||
//{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user