diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 21caa36..d762167 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -2512,12 +2512,12 @@ namespace SolarPower.Repository.Implement FROM( SELECT 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 SELECT d.* FROM {db_name}.sharedevice sd 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 ORDER BY temp.ColName "; diff --git a/solarApp/Service/getStationSvc.cs b/solarApp/Service/getStationSvc.cs index dec4842..d95b6fe 100644 --- a/solarApp/Service/getStationSvc.cs +++ b/solarApp/Service/getStationSvc.cs @@ -179,7 +179,7 @@ namespace solarApp.Service conn.Open(); // 01 控制器編號 string sql = @" select id, CompanyId, `code` , SerialNumber, CONCAT(`code` ,'01') SiteID, SiteDB, `name` SiteName from power_station - where deleted = 0 and `status`= 1 "; + where deleted = 0 and `status`= 1"; List ds = conn.Query(sql).AsList(); conn.Close(); return ds; diff --git a/solarApp/Service/procSensorSvc.cs b/solarApp/Service/procSensorSvc.cs index f97611d..15f4fc0 100644 --- a/solarApp/Service/procSensorSvc.cs +++ b/solarApp/Service/procSensorSvc.cs @@ -164,6 +164,7 @@ namespace solarApp.Service } bool insert_sensor() { + procArchiveLog arclog = new procArchiveLog(); bool result = false; using (MySqlConnection conn = new MySqlConnection(Connection1)) { @@ -222,7 +223,7 @@ namespace solarApp.Service #endregion //電表 - + DateTime dt_start = DateTime.Now; #endregion 獲取 Sensor 類別 try { @@ -260,8 +261,12 @@ namespace solarApp.Service cmd.Parameters.AddWithValue("@powerStationID", _powerStationID); cmd.Parameters.AddWithValue("@date1", _date1); cmd.CommandText = sql; - cmd.ExecuteNonQuery(); + int rowCT = cmd.ExecuteNonQuery(); 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 #region day diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index ed8f091..2e29f1a 100644 --- a/solarApp/Service/procStationSvc.cs +++ b/solarApp/Service/procStationSvc.cs @@ -135,6 +135,8 @@ namespace solarApp.Service } bool insert_station() { + procArchiveLog arclog = new procArchiveLog(); + DateTime dt_start = DateTime.Now; bool result = false; try { @@ -211,8 +213,12 @@ namespace solarApp.Service cmd.Parameters.AddWithValue("@date1", _date1); cmd.Parameters.AddWithValue("@siteID", _siteID); cmd.CommandText = sql; - cmd.ExecuteNonQuery(); + int rowCT = cmd.ExecuteNonQuery(); 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 //#region 取累計日照量 diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs index acb31ab..721f189 100644 --- a/solarApp/fmArchive.Designer.cs +++ b/solarApp/fmArchive.Designer.cs @@ -54,6 +54,7 @@ namespace solarApp this.gv_inv_detail = new System.Windows.Forms.DataGridView(); this.gv_rpt_invDay = new System.Windows.Forms.DataGridView(); this.panel1 = new System.Windows.Forms.Panel(); + this.lbMsgTitle = new System.Windows.Forms.Label(); this.bt_invDay = new System.Windows.Forms.Button(); this.btVerifyData = new System.Windows.Forms.Button(); this.lbSiteDB_sensor = new System.Windows.Forms.Label(); @@ -79,7 +80,7 @@ namespace solarApp this.tbUserName = new System.Windows.Forms.TextBox(); this.btSendMail = new System.Windows.Forms.Button(); 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.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -129,6 +130,7 @@ namespace solarApp // splitContainer1.Panel1 // 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_sensor_lackData); this.splitContainer1.Panel1.Controls.Add(this.bt_updateInstantValue); @@ -231,11 +233,11 @@ namespace solarApp // 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.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.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.Text = "單日歸檔"; + this.bt_archive.Text = "時間區間/全電站"; this.bt_archive.UseVisualStyleBackColor = true; 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.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 // 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.Click += new System.EventHandler(this.btSendMail_Click); // - // lbMsgTitle + // bt_archive_One // - 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"; + this.bt_archive_One.Location = new System.Drawing.Point(10, 850); + this.bt_archive_One.Name = "bt_archive_One"; + this.bt_archive_One.Size = new System.Drawing.Size(166, 57); + this.bt_archive_One.TabIndex = 16; + this.bt_archive_One.Text = "時間區間/單電站"; + this.bt_archive_One.UseVisualStyleBackColor = true; + this.bt_archive_One.Click += new System.EventHandler(this.bt_archive_One_Click); // // fmArchive // @@ -726,5 +738,6 @@ namespace solarApp private System.Windows.Forms.Label lbReceiver; private System.Windows.Forms.TextBox tbReceiver; private System.Windows.Forms.Label lbMsgTitle; + private System.Windows.Forms.Button bt_archive_One; } } \ No newline at end of file diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs index ef06a17..a635c20 100644 --- a/solarApp/fmArchive.cs +++ b/solarApp/fmArchive.cs @@ -457,6 +457,32 @@ namespace solarApp 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) { var site_list = stationSvc.get_station_list();