diff --git a/solarApp/Model/sensor_model.cs b/solarApp/Model/sensor_model.cs
index 02bac14..e9e9d0e 100644
--- a/solarApp/Model/sensor_model.cs
+++ b/solarApp/Model/sensor_model.cs
@@ -26,6 +26,19 @@ namespace solarApp.Model
public double sensorAvg06 { get; set; }
}
+ public class lackData
+ {
+ public int powerstationid { get; set; }
+ public string SITEID { get; set; }
+ public DateTime TIMESTAMP { get; set; }
+ public double TODAYKWH { get; set; }
+ public double TOTALKWH { get; set; }
+ public double Irradiance { get; set; }
+ public double EnvTemperature { get; set; }
+ public double irrDay { get; set; }
+ }
+
+
public class sensor_raw_V2
{
public string SiteID { get; set; }
diff --git a/solarApp/Service/getSensorSvc.cs b/solarApp/Service/getSensorSvc.cs
index b8a4177..eea3410 100644
--- a/solarApp/Service/getSensorSvc.cs
+++ b/solarApp/Service/getSensorSvc.cs
@@ -33,6 +33,32 @@ namespace solarApp.Service
}
}
+ ///
+ /// 取得需要補償的 Sensor 資料
+ ///
+ ///
+ ///
+ public List get_lack_sensorData(string reportDate)
+ {
+ using (MySqlConnection conn = new MySqlConnection(Connection1))
+ {
+ conn.Open();
+ string sql = @" select a.powerstationid, p.`code` SITEID, a.`TIMESTAMP` , TODAYKWH, TOTALKWH , b.Irradiance, b.EnvTemperature, b.irrDay #累計日照量
+ from power_station_history_hour a
+ left join (
+ select PowerStationID, `TIMESTAMP` , Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay
+ from sensor_history_hour
+ where left(`TIMESTAMP`, 7) = @reportDate and hour(`TIMESTAMP`) = 12
+ ) b on a.powerstationid = b.powerstationid and a.`TIMESTAMP` = b.`TIMESTAMP`
+ join power_station p on a.powerstationid = p.id
+ where left(a.`TIMESTAMP`, 7) = @reportDate and hour(a.`TIMESTAMP`) = 12 and b.Irradiance is null
+ order by 1, 2";
+ List ds = conn.Query(sql, new { reportDate = reportDate.Substring(0, 7) }).AsList();
+ conn.Close();
+ return ds;
+ }
+ }
+
///
/// Sensor 欄位需要平均時 欄位串接 (s1 + s2) / 2
///
diff --git a/solarApp/Service/getStationSvc.cs b/solarApp/Service/getStationSvc.cs
index 39a78ad..8fa46d1 100644
--- a/solarApp/Service/getStationSvc.cs
+++ b/solarApp/Service/getStationSvc.cs
@@ -185,5 +185,26 @@ namespace solarApp.Service
return ds;
}
}
+
+ public List get_lack_stationData(string reportDate)
+ {
+ using (MySqlConnection conn = new MySqlConnection(Connection1))
+ {
+ conn.Open(); // a.powerstationid, p.`code` SITEID, a.`TIMESTAMP` , TODAYKWH, TOTALKWH , b.Irradiance, b.EnvTemperature, b.irrDay
+ string sql = @"select a.powerstationid, p.`code` SITEID, left(a.`TIMESTAMP`, 10) `TIMESTAMP`, b.TODAYKWH, b.TOTALKWH
+ from sensor_history_hour a
+ left join (
+ select powerstationid, left(`TIMESTAMP`, 10) `TIMESTAMP` , TODAYKWH, TOTALKWH from power_station_history_hour
+ where left(`TIMESTAMP`, 7) = @reportDate and hour(`TIMESTAMP`) = 12
+ ) b on a.powerstationid = b.powerstationid and left(a.`TIMESTAMP`, 10) = b.`TIMESTAMP`
+ join power_station p on a.powerstationid = p.id
+ where left(a.`TIMESTAMP`, 7) = @reportDate and hour(a.`TIMESTAMP`) = 12 and b.TODAYKWH is null
+ order by 1, 2 ";
+ List ds = conn.Query(sql, new { reportDate = reportDate.Substring(0, 7) }, commandTimeout: 300).AsList();
+
+ conn.Close();
+ return ds;
+ }
+ }
}
}
diff --git a/solarApp/Service/procInvSvc.cs b/solarApp/Service/procInvSvc.cs
index a1fbb9e..b96a29a 100644
--- a/solarApp/Service/procInvSvc.cs
+++ b/solarApp/Service/procInvSvc.cs
@@ -369,7 +369,8 @@ namespace solarApp.Service
select concat(DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
from sensor_history_hour
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
- )irr on a.reportDate = irr.reportDate; ";
+ )irr on a.reportDate = irr.reportDate
+ where i.enabled = 1;";
//int ct = conn.Execute(sql, new { date1 = _date1 });
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
@@ -518,7 +519,8 @@ namespace solarApp.Service
select DATE_FORMAT(a.TIMESTAMP, '%Y-%m') AS reportDate, Irradiance
from sensor_history_month a
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1 and Irradiance <> 0
- )irr on a.reportDate = irr.reportDate ;";
+ )irr on a.reportDate = irr.reportDate
+ where i.enabled = 1;";
//conn.Execute(sql, new { date1 = _date1.Substring(0, 7), PowerStationID = _powerStationID });
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs
index 301cd21..0327a3b 100644
--- a/solarApp/fmArchive.Designer.cs
+++ b/solarApp/fmArchive.Designer.cs
@@ -29,11 +29,13 @@ namespace solarApp
///
private void InitializeComponent()
{
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+ this.bt_sensor_lackData = new System.Windows.Forms.Button();
+ this.btInvDay_oldData = new System.Windows.Forms.Button();
this.bt_rpt_invDay = new System.Windows.Forms.Button();
this.bt_meter = new System.Windows.Forms.Button();
this.lbmsg = new System.Windows.Forms.Label();
@@ -69,7 +71,7 @@ namespace solarApp
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
- this.btInvDay_oldData = new System.Windows.Forms.Button();
+ this.bt_lackStation = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -120,6 +122,8 @@ namespace solarApp
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
+ this.splitContainer1.Panel1.Controls.Add(this.bt_lackStation);
+ this.splitContainer1.Panel1.Controls.Add(this.bt_sensor_lackData);
this.splitContainer1.Panel1.Controls.Add(this.btInvDay_oldData);
this.splitContainer1.Panel1.Controls.Add(this.bt_rpt_invDay);
this.splitContainer1.Panel1.Controls.Add(this.bt_meter);
@@ -145,6 +149,28 @@ namespace solarApp
this.splitContainer1.SplitterWidth = 10;
this.splitContainer1.TabIndex = 0;
//
+ // bt_sensor_lackData
+ //
+ this.bt_sensor_lackData.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.bt_sensor_lackData.Location = new System.Drawing.Point(297, 635);
+ this.bt_sensor_lackData.Name = "bt_sensor_lackData";
+ this.bt_sensor_lackData.Size = new System.Drawing.Size(107, 44);
+ this.bt_sensor_lackData.TabIndex = 14;
+ this.bt_sensor_lackData.Text = "LackData";
+ this.bt_sensor_lackData.UseVisualStyleBackColor = true;
+ this.bt_sensor_lackData.Click += new System.EventHandler(this.bt_sensor_lackData_Click);
+ //
+ // btInvDay_oldData
+ //
+ this.btInvDay_oldData.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.btInvDay_oldData.Location = new System.Drawing.Point(156, 790);
+ this.btInvDay_oldData.Name = "btInvDay_oldData";
+ this.btInvDay_oldData.Size = new System.Drawing.Size(100, 44);
+ this.btInvDay_oldData.TabIndex = 13;
+ this.btInvDay_oldData.Text = "日報-舊";
+ this.btInvDay_oldData.UseVisualStyleBackColor = true;
+ this.btInvDay_oldData.Click += new System.EventHandler(this.btInvDay_oldData_Click);
+ //
// bt_rpt_invDay
//
this.bt_rpt_invDay.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
@@ -283,8 +309,8 @@ namespace solarApp
//
this.gv_inv_detail.AllowUserToAddRows = false;
this.gv_inv_detail.AllowUserToDeleteRows = false;
- dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
+ dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
+ this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5;
this.gv_inv_detail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gv_inv_detail.Dock = System.Windows.Forms.DockStyle.Fill;
this.gv_inv_detail.Location = new System.Drawing.Point(768, 75);
@@ -300,8 +326,8 @@ namespace solarApp
//
this.gv_rpt_invDay.AllowUserToAddRows = false;
this.gv_rpt_invDay.AllowUserToDeleteRows = false;
- dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
+ dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
+ this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6;
this.gv_rpt_invDay.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gv_rpt_invDay.Dock = System.Windows.Forms.DockStyle.Left;
this.gv_rpt_invDay.Location = new System.Drawing.Point(0, 75);
@@ -538,16 +564,16 @@ namespace solarApp
this.label4.TabIndex = 9;
this.label4.Text = "Site_Name";
//
- // btInvDay_oldData
+ // bt_lackStation
//
- this.btInvDay_oldData.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.btInvDay_oldData.Location = new System.Drawing.Point(156, 790);
- this.btInvDay_oldData.Name = "btInvDay_oldData";
- this.btInvDay_oldData.Size = new System.Drawing.Size(100, 44);
- this.btInvDay_oldData.TabIndex = 13;
- this.btInvDay_oldData.Text = "日報-舊";
- this.btInvDay_oldData.UseVisualStyleBackColor = true;
- this.btInvDay_oldData.Click += new System.EventHandler(this.btInvDay_oldData_Click);
+ this.bt_lackStation.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.bt_lackStation.Location = new System.Drawing.Point(300, 735);
+ this.bt_lackStation.Name = "bt_lackStation";
+ this.bt_lackStation.Size = new System.Drawing.Size(107, 44);
+ this.bt_lackStation.TabIndex = 15;
+ this.bt_lackStation.Text = "LackData";
+ this.bt_lackStation.UseVisualStyleBackColor = true;
+ this.bt_lackStation.Click += new System.EventHandler(this.bt_lackStation_Click);
//
// fmArchive
//
@@ -624,5 +650,7 @@ namespace solarApp
private System.Windows.Forms.Button bt_invDay;
private System.Windows.Forms.DataGridView gv_inv_detail;
private System.Windows.Forms.Button btInvDay_oldData;
+ private System.Windows.Forms.Button bt_sensor_lackData;
+ private System.Windows.Forms.Button bt_lackStation;
}
}
\ No newline at end of file
diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs
index d868a09..9703a54 100644
--- a/solarApp/fmArchive.cs
+++ b/solarApp/fmArchive.cs
@@ -344,6 +344,37 @@ namespace solarApp
//{
// invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
//}
+ }
+
+ private void bt_sensor_lackData_Click(object sender, EventArgs e)
+ {
+ procSensorSvc sensorSvc = new procSensorSvc();
+ getSensorSvc GetSensor = new getSensorSvc();
+ var ds = GetSensor.get_lack_sensorData(dtSelect1.Value.ToString("yyyy-MM-dd"));
+ //foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
+ foreach (var item in ds)
+ {
+ sensorSvc.archiveData(item.SITEID, item.TIMESTAMP.ToString("yyyy-MM-dd"));
+ }
+
+ MessageBox.Show("OK");
+ }
+
+ private void bt_lackStation_Click(object sender, EventArgs e)
+ {
+ procStationSvc stationSvc = new procStationSvc();
+ getStationSvc GetStation = new getStationSvc();
+ var ds = GetStation.get_lack_stationData(dtSelect1.Value.ToString("yyyy-MM-dd"));
+
+ procInvSvc invSvc = new procInvSvc();
+ //foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
+ foreach (var item in ds)
+ {
+ stationSvc.archiveData(item.SITEID, item.TIMESTAMP.ToString("yyyy-MM-dd")); // 補 station
+ invSvc.report_invDay(item.SITEID, item.TIMESTAMP.ToString("yyyy-MM-dd")); // 補日報表
+ }
+
+ MessageBox.Show("OK");
}
}
}