逆變器交叉分析 - sensor原日照計改成 select 累計日照計

This commit is contained in:
cesar liu 2022-07-04 14:57:24 +08:00
parent 9c7c834002
commit f7c9e6a719
6 changed files with 67 additions and 17 deletions

View File

@ -2512,12 +2512,12 @@ namespace SolarPower.Repository.Implement
FROM( FROM(
SELECT d.* SELECT d.*
FROM {db_name}.device d FROM {db_name}.device d
WHERE d.PowerStationId = @PowerStationId AND d.`Type` = 'PYR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 WHERE d.PowerStationId = @PowerStationId AND d.`Type` = 'TPY' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0
UNION UNION
SELECT d.* SELECT d.*
FROM {db_name}.sharedevice sd FROM {db_name}.sharedevice sd
LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id
WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = 'PYR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = 'TPY' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0
) temp ) temp
ORDER BY temp.ColName ORDER BY temp.ColName
"; ";

View File

@ -179,7 +179,7 @@ namespace solarApp.Service
conn.Open(); // 01 控制器編號 conn.Open(); // 01 控制器編號
string sql = @" select id, CompanyId, `code` , SerialNumber, CONCAT(`code` ,'01') SiteID, SiteDB, `name` SiteName string sql = @" select id, CompanyId, `code` , SerialNumber, CONCAT(`code` ,'01') SiteID, SiteDB, `name` SiteName
from power_station from power_station
where deleted = 0 and `status`= 1 "; where deleted = 0 and `status`= 1";
List<station_list> ds = conn.Query<station_list>(sql).AsList<station_list>(); List<station_list> ds = conn.Query<station_list>(sql).AsList<station_list>();
conn.Close(); conn.Close();
return ds; return ds;

View File

@ -164,6 +164,7 @@ namespace solarApp.Service
} }
bool insert_sensor() bool insert_sensor()
{ {
procArchiveLog arclog = new procArchiveLog();
bool result = false; bool result = false;
using (MySqlConnection conn = new MySqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
@ -222,7 +223,7 @@ namespace solarApp.Service
#endregion #endregion
//電表 //電表
DateTime dt_start = DateTime.Now;
#endregion Sensor #endregion Sensor
try try
{ {
@ -260,8 +261,12 @@ namespace solarApp.Service
cmd.Parameters.AddWithValue("@powerStationID", _powerStationID); cmd.Parameters.AddWithValue("@powerStationID", _powerStationID);
cmd.Parameters.AddWithValue("@date1", _date1); cmd.Parameters.AddWithValue("@date1", _date1);
cmd.CommandText = sql; cmd.CommandText = sql;
cmd.ExecuteNonQuery(); int rowCT = cmd.ExecuteNonQuery();
cmd.Parameters.Clear(); cmd.Parameters.Clear();
DateTime dt_start2 = DateTime.Now;
TimeSpan duration = DateTime.Now - dt_start2;
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "0", "", rowCT.ToString(), conn, cmd);
#endregion hour #endregion hour
#region day #region day

View File

@ -135,6 +135,8 @@ namespace solarApp.Service
} }
bool insert_station() bool insert_station()
{ {
procArchiveLog arclog = new procArchiveLog();
DateTime dt_start = DateTime.Now;
bool result = false; bool result = false;
try try
{ {
@ -211,8 +213,12 @@ namespace solarApp.Service
cmd.Parameters.AddWithValue("@date1", _date1); cmd.Parameters.AddWithValue("@date1", _date1);
cmd.Parameters.AddWithValue("@siteID", _siteID); cmd.Parameters.AddWithValue("@siteID", _siteID);
cmd.CommandText = sql; cmd.CommandText = sql;
cmd.ExecuteNonQuery(); int rowCT = cmd.ExecuteNonQuery();
cmd.Parameters.Clear(); cmd.Parameters.Clear();
DateTime dt_start2 = DateTime.Now;
TimeSpan duration = DateTime.Now - dt_start2;
arclog.insert_log(_powerStationID, "station step1", duration.TotalSeconds, "power_station_history_hour", "insert station hour", "0", "", rowCT.ToString(), conn, cmd);
#endregion hour #endregion hour
//#region 取累計日照量 //#region 取累計日照量

View File

@ -54,6 +54,7 @@ namespace solarApp
this.gv_inv_detail = new System.Windows.Forms.DataGridView(); this.gv_inv_detail = new System.Windows.Forms.DataGridView();
this.gv_rpt_invDay = new System.Windows.Forms.DataGridView(); this.gv_rpt_invDay = new System.Windows.Forms.DataGridView();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.lbMsgTitle = new System.Windows.Forms.Label();
this.bt_invDay = new System.Windows.Forms.Button(); this.bt_invDay = new System.Windows.Forms.Button();
this.btVerifyData = new System.Windows.Forms.Button(); this.btVerifyData = new System.Windows.Forms.Button();
this.lbSiteDB_sensor = new System.Windows.Forms.Label(); this.lbSiteDB_sensor = new System.Windows.Forms.Label();
@ -79,7 +80,7 @@ namespace solarApp
this.tbUserName = new System.Windows.Forms.TextBox(); this.tbUserName = new System.Windows.Forms.TextBox();
this.btSendMail = new System.Windows.Forms.Button(); this.btSendMail = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.lbMsgTitle = new System.Windows.Forms.Label(); this.bt_archive_One = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -129,6 +130,7 @@ namespace solarApp
// splitContainer1.Panel1 // splitContainer1.Panel1
// //
this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption; this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.splitContainer1.Panel1.Controls.Add(this.bt_archive_One);
this.splitContainer1.Panel1.Controls.Add(this.bt_lackStation); this.splitContainer1.Panel1.Controls.Add(this.bt_lackStation);
this.splitContainer1.Panel1.Controls.Add(this.bt_sensor_lackData); this.splitContainer1.Panel1.Controls.Add(this.bt_sensor_lackData);
this.splitContainer1.Panel1.Controls.Add(this.bt_updateInstantValue); this.splitContainer1.Panel1.Controls.Add(this.bt_updateInstantValue);
@ -231,11 +233,11 @@ namespace solarApp
// bt_archive // bt_archive
// //
this.bt_archive.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.bt_archive.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_archive.Location = new System.Drawing.Point(9, 846); this.bt_archive.Location = new System.Drawing.Point(208, 846);
this.bt_archive.Name = "bt_archive"; this.bt_archive.Name = "bt_archive";
this.bt_archive.Size = new System.Drawing.Size(220, 61); this.bt_archive.Size = new System.Drawing.Size(189, 61);
this.bt_archive.TabIndex = 8; this.bt_archive.TabIndex = 8;
this.bt_archive.Text = "單日歸檔"; this.bt_archive.Text = "時間區間/全電站";
this.bt_archive.UseVisualStyleBackColor = true; this.bt_archive.UseVisualStyleBackColor = true;
this.bt_archive.Click += new System.EventHandler(this.bt_archive_Click); this.bt_archive.Click += new System.EventHandler(this.bt_archive_Click);
// //
@ -374,6 +376,15 @@ namespace solarApp
this.panel1.Size = new System.Drawing.Size(1358, 75); this.panel1.Size = new System.Drawing.Size(1358, 75);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
// //
// lbMsgTitle
//
this.lbMsgTitle.AutoSize = true;
this.lbMsgTitle.Location = new System.Drawing.Point(931, 20);
this.lbMsgTitle.Name = "lbMsgTitle";
this.lbMsgTitle.Size = new System.Drawing.Size(51, 19);
this.lbMsgTitle.TabIndex = 15;
this.lbMsgTitle.Text = "label2";
//
// bt_invDay // bt_invDay
// //
this.bt_invDay.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.bt_invDay.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
@ -634,14 +645,15 @@ namespace solarApp
this.btSendMail.UseVisualStyleBackColor = true; this.btSendMail.UseVisualStyleBackColor = true;
this.btSendMail.Click += new System.EventHandler(this.btSendMail_Click); this.btSendMail.Click += new System.EventHandler(this.btSendMail_Click);
// //
// lbMsgTitle // bt_archive_One
// //
this.lbMsgTitle.AutoSize = true; this.bt_archive_One.Location = new System.Drawing.Point(10, 850);
this.lbMsgTitle.Location = new System.Drawing.Point(931, 20); this.bt_archive_One.Name = "bt_archive_One";
this.lbMsgTitle.Name = "lbMsgTitle"; this.bt_archive_One.Size = new System.Drawing.Size(166, 57);
this.lbMsgTitle.Size = new System.Drawing.Size(51, 19); this.bt_archive_One.TabIndex = 16;
this.lbMsgTitle.TabIndex = 15; this.bt_archive_One.Text = "時間區間/單電站";
this.lbMsgTitle.Text = "label2"; this.bt_archive_One.UseVisualStyleBackColor = true;
this.bt_archive_One.Click += new System.EventHandler(this.bt_archive_One_Click);
// //
// fmArchive // fmArchive
// //
@ -726,5 +738,6 @@ namespace solarApp
private System.Windows.Forms.Label lbReceiver; private System.Windows.Forms.Label lbReceiver;
private System.Windows.Forms.TextBox tbReceiver; private System.Windows.Forms.TextBox tbReceiver;
private System.Windows.Forms.Label lbMsgTitle; private System.Windows.Forms.Label lbMsgTitle;
private System.Windows.Forms.Button bt_archive_One;
} }
} }

View File

@ -457,6 +457,32 @@ namespace solarApp
lbMsgTitle.Text = DateTime.Now.ToString() + " lackStation OK"; lbMsgTitle.Text = DateTime.Now.ToString() + " lackStation OK";
} }
private void bt_archive_One_Click(object sender, EventArgs e)
{
int i = 0;
//var site_list = stationSvc.get_station_list();
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();
//foreach (var item in site_list)
//{
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
}
i++;
//}
lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!";
}
private void bt_updateInstantValue_Click(object sender, EventArgs e) private void bt_updateInstantValue_Click(object sender, EventArgs e)
{ {
var site_list = stationSvc.get_station_list(); var site_list = stationSvc.get_station_list();