From 7f4fe753dc13135bdc58722d44b292fb906c7ddc Mon Sep 17 00:00:00 2001 From: JiaHao Liu Date: Wed, 18 Aug 2021 17:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AA=A2=E6=A0=B8=E8=A3=9C=E4=B8=8A=20Sensor?= =?UTF-8?q?=20=E6=AF=8F=E5=A4=A9=E7=9A=84=E7=AD=86=E6=95=B8=E6=AA=A2?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Service/getSensorSvc.cs | 12 ++++++++++-- solarApp/fmMain.Designer.cs | 3 ++- solarApp/fmMain.cs | 11 +++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/solarApp/Service/getSensorSvc.cs b/solarApp/Service/getSensorSvc.cs index 94a2e34..1be0d83 100644 --- a/solarApp/Service/getSensorSvc.cs +++ b/solarApp/Service/getSensorSvc.cs @@ -151,9 +151,17 @@ namespace solarApp.Service using (MySqlConnection conn = new MySqlConnection(Connection1)) { conn.Open(); - string sql = @" select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H') reportdate, b.`code` siteid, round(Irradiance, 2) irrAvg, round(Temperature, 2) modelTempAvg + //string sql = @" select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H') reportdate, b.`code` siteid, round(Irradiance, 2) irrAvg, round(Temperature, 2) modelTempAvg + // from sensor_history_day a join power_station b on a.PowerStationId = b.id + // where left(`TIMESTAMP`, 10) between '" + date1 + "' and '"+date2+"' and b.`code` = @siteID"; + string sql = @"select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H') reportdate, b.`code` siteid, round(Irradiance, 2) irrAvg, round(Temperature, 2) modelTempAvg, c.count from sensor_history_day a join power_station b on a.PowerStationId = b.id - where left(`TIMESTAMP`, 10) between '" + date1 + "' and '"+date2+"' and b.`code` = @siteID"; + join ( + select PowerStationId, left(a.`TIMESTAMP`, 10) reportDate, count(*) count from sensor_history_hour a join power_station b on a.PowerStationId = b.id + where b.`code` = @siteID and left(`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + @"' + group by PowerStationId, left(a.`TIMESTAMP`, 10) + )c on a.PowerStationId = c.PowerStationId and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = c.reportDate + where left(a.`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + @"' and b.`code` = @siteID"; List ds = conn.Query(sql, new { siteID = siteID }).AsList(); conn.Close(); return ds; diff --git a/solarApp/fmMain.Designer.cs b/solarApp/fmMain.Designer.cs index 24a81cb..7f67405 100644 --- a/solarApp/fmMain.Designer.cs +++ b/solarApp/fmMain.Designer.cs @@ -1409,6 +1409,7 @@ namespace solarApp this.gv_web_sensor_day.RowTemplate.Height = 25; this.gv_web_sensor_day.Size = new System.Drawing.Size(666, 253); this.gv_web_sensor_day.TabIndex = 4; + this.gv_web_sensor_day.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gv_web_sensor_day_CellFormatting); // // panel12 // @@ -1649,7 +1650,7 @@ namespace solarApp this.Controls.Add(this.tabControl1); this.Name = "fmMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "太陽能電站數據檢核 V0729"; + this.Text = "太陽能電站數據檢核 V0817"; this.Load += new System.EventHandler(this.fmMain_Load); this.tabControl1.ResumeLayout(false); this.tb_inv.ResumeLayout(false); diff --git a/solarApp/fmMain.cs b/solarApp/fmMain.cs index 71c2245..9dc3d64 100644 --- a/solarApp/fmMain.cs +++ b/solarApp/fmMain.cs @@ -267,5 +267,16 @@ namespace solarApp } } } + + private void gv_web_sensor_day_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Value != null && !string.IsNullOrWhiteSpace(gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Value.ToString())) + { + if (gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Value.ToString() != "24") + { + gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Style = new DataGridViewCellStyle { ForeColor = Color.Red, BackColor = Color.White }; + } + } + } } }