debug: 電站啟用時, 增加欄位 InsertTime
This commit is contained in:
parent
e87d8b89e4
commit
0bd4791496
@ -44,7 +44,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
if (this.environment.IsDevelopment())
|
||||
{
|
||||
dateTime = "2021-11-02 10";
|
||||
dateTime = "2022-06-01 16";
|
||||
}
|
||||
|
||||
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
|
||||
@ -636,7 +636,18 @@ namespace SolarPower.Quartz.Jobs
|
||||
if (powerStation.Coordinate != null)
|
||||
{
|
||||
var powerLocation = powerStation.Coordinate.Split(',');
|
||||
var nowLocation = Math.Sqrt(Math.Pow(Convert.ToDouble(powerLocation[0]) - Convert.ToDouble(Location.Lat), 2) + Math.Pow(Convert.ToDouble(powerLocation[1]) - Convert.ToDouble(Location.Lon), 2));
|
||||
double p1 = Convert.ToDouble(powerLocation[0]);
|
||||
double p2 = Convert.ToDouble(powerLocation[1]);
|
||||
double dLat = Convert.ToDouble(Location.Lat);
|
||||
double dLon = Convert.ToDouble(Location.Lon);
|
||||
double x = Math.Pow(p1 - dLat, 2) ;
|
||||
double y = Math.Pow(p2 - dLon, 2);
|
||||
var nowLocation = Math.Sqrt(x + y);
|
||||
//var nowLocation = Math.Sqrt(Math.Pow(Convert.ToDouble(powerLocation[0])
|
||||
// - Convert.ToDouble(Location.Lat), 2)
|
||||
// + Math.Pow(Convert.ToDouble(powerLocation[1])
|
||||
// - Convert.ToDouble(Location.Lon), 2)
|
||||
// );
|
||||
if (nowLocation < shortLocation)
|
||||
{
|
||||
shortLocation = nowLocation;
|
||||
@ -689,7 +700,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
if (!this.environment.IsDevelopment())
|
||||
{
|
||||
#region step3. 將historiers INSERT 到 power_station_history_hour 資料表
|
||||
@ -713,7 +724,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
"TODAYCARBON",
|
||||
"TOTALCARBON"
|
||||
};
|
||||
|
||||
logger.LogInformation("【Insert PowerStationHistoryHour】【開始寫入 PowerStationHistoryHour 資料】", dateTime);
|
||||
await powerStationRepository.AddPowerStationHistory(powerStationHistoriesHour, history_properties);
|
||||
#endregion
|
||||
|
||||
@ -764,7 +775,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
"TodayWeather",
|
||||
"RateOfRain"
|
||||
};
|
||||
|
||||
logger.LogInformation("【update Power_Station 】【update Power_Station】", dateTime);
|
||||
await powerStationRepository.UpdateList(calcPowerStations, power_station_properties);
|
||||
#endregion
|
||||
|
||||
|
||||
@ -6025,7 +6025,9 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
try
|
||||
{
|
||||
var sql = $@"ALTER TABLE {dbname}.s{code}01_inv ADD COLUMN CrdTime datetime;
|
||||
var sql = $@"
|
||||
ALTER TABLE {dbname}.s{code}01_inv add column `insertTime` datetime Default CURRENT_TIMESTAMP;
|
||||
ALTER TABLE {dbname}.s{code}01_inv ADD COLUMN CrdTime datetime;
|
||||
use {dbname};
|
||||
create trigger trg01_s{code}01_inv
|
||||
before insert on {dbname}.s{code}01_inv
|
||||
@ -6061,7 +6063,9 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
try
|
||||
{
|
||||
var sql = $@"ALTER TABLE {dbname}.s{code}01_sensoravg ADD COLUMN CrdTime datetime;
|
||||
var sql = $@"
|
||||
ALTER TABLE {dbname}.s{code}01_sensoravg add column `insertTime` datetime Default CURRENT_TIMESTAMP;
|
||||
ALTER TABLE {dbname}.s{code}01_sensoravg ADD COLUMN CrdTime datetime;
|
||||
use {dbname};
|
||||
create trigger trg01_s{code}01_sensoravg
|
||||
before insert on {dbname}.s{code}01_sensoravg
|
||||
@ -6096,7 +6100,8 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
try
|
||||
{
|
||||
var sql = $@" CREATE INDEX idx_s{code}01_station_TIMESTAMP ON {dbname}.s{code}01_station (`TIMESTAMP` DESC);";
|
||||
var sql = $@" CREATE INDEX idx_s{code}01_station_TIMESTAMP ON {dbname}.s{code}01_station (`TIMESTAMP` DESC);
|
||||
alter table {dbname}.s{code}01_station add column `insertTime` datetime Default CURRENT_TIMESTAMP;";
|
||||
await conn.ExecuteAsync(sql);
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@ -363,5 +363,31 @@ namespace solarApp.Service
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool update_powerStationPerHour(string table_name) {
|
||||
//WeathersStationId, TodayWeatherTemp, TodayWeather, RateOfRain
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
string sql = $@"
|
||||
SELECT
|
||||
DATE_FORMAT(FROM_UNIXTIME(timestamp / 1000), '%Y-%m-%d %H') AS TIMESTAMP,
|
||||
SITEID, SiteType, KWH, TodayKWh, TotalKWH, KWHKWP, PR, MP, SolarHour
|
||||
FROM {table_name} WHERE DATE_FORMAT(FROM_UNIXTIME(timestamp / 1000), '%Y-%m-%d %H') = @DateTime ";
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
//result = await conn.QueryFirstOrDefaultAsync<PowerStationHistory>(sql, new { DateTime = dateTime });
|
||||
|
||||
//string col = $@"select Id, kwh, Today_kwh, Total_kwh, today_kwhkwp, today_money, total_money, today_PR, today_carbon, total_carbon, today_irradiance, SolarHour";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
solarApp/fmArchive.Designer.cs
generated
38
solarApp/fmArchive.Designer.cs
generated
@ -30,14 +30,14 @@ namespace solarApp
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = 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_lackStation = new System.Windows.Forms.Button();
|
||||
this.bt_sensor_lackData = new System.Windows.Forms.Button();
|
||||
this.btInvDay_oldData = new System.Windows.Forms.Button();
|
||||
this.bt_updateInstantValue = 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();
|
||||
@ -126,7 +126,7 @@ namespace solarApp
|
||||
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_updateInstantValue);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_rpt_invDay);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_meter);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lbmsg);
|
||||
@ -175,16 +175,16 @@ namespace solarApp
|
||||
this.bt_sensor_lackData.Visible = false;
|
||||
this.bt_sensor_lackData.Click += new System.EventHandler(this.bt_sensor_lackData_Click);
|
||||
//
|
||||
// btInvDay_oldData
|
||||
// bt_updateInstantValue
|
||||
//
|
||||
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_updateInstantValue.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_updateInstantValue.Location = new System.Drawing.Point(156, 790);
|
||||
this.bt_updateInstantValue.Name = "bt_updateInstantValue";
|
||||
this.bt_updateInstantValue.Size = new System.Drawing.Size(100, 44);
|
||||
this.bt_updateInstantValue.TabIndex = 13;
|
||||
this.bt_updateInstantValue.Text = "即時資料";
|
||||
this.bt_updateInstantValue.UseVisualStyleBackColor = true;
|
||||
this.bt_updateInstantValue.Click += new System.EventHandler(this.bt_updateInstantValue_Click);
|
||||
//
|
||||
// bt_rpt_invDay
|
||||
//
|
||||
@ -202,7 +202,7 @@ namespace solarApp
|
||||
this.bt_meter.Location = new System.Drawing.Point(10, 786);
|
||||
this.bt_meter.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.bt_meter.Name = "bt_meter";
|
||||
this.bt_meter.Size = new System.Drawing.Size(135, 56);
|
||||
this.bt_meter.Size = new System.Drawing.Size(119, 56);
|
||||
this.bt_meter.TabIndex = 11;
|
||||
this.bt_meter.Text = "Meter歸檔";
|
||||
this.bt_meter.UseVisualStyleBackColor = true;
|
||||
@ -324,8 +324,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;
|
||||
dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
|
||||
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);
|
||||
@ -341,8 +341,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;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4;
|
||||
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);
|
||||
@ -653,7 +653,7 @@ namespace solarApp
|
||||
private System.Windows.Forms.Label label4;
|
||||
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_updateInstantValue;
|
||||
private System.Windows.Forms.Button bt_sensor_lackData;
|
||||
private System.Windows.Forms.Button bt_lackStation;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
|
||||
@ -368,15 +368,6 @@ namespace solarApp
|
||||
gv_inv_detail.Columns[3].Width = 100;
|
||||
gv_inv_detail.Columns[4].Width = 80;
|
||||
gv_inv_detail.Columns[5].Width = 80;
|
||||
}
|
||||
|
||||
private void btInvDay_oldData_Click(object sender, EventArgs e)
|
||||
{
|
||||
//procInvSvc invSvc = new procInvSvc();
|
||||
//foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
//{
|
||||
// invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
//}
|
||||
}
|
||||
|
||||
private void bt_sensor_lackData_Click(object sender, EventArgs e)
|
||||
@ -409,5 +400,25 @@ namespace solarApp
|
||||
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
|
||||
private void bt_updateInstantValue_Click(object sender, EventArgs e)
|
||||
{
|
||||
var site_list = stationSvc.get_station_list();
|
||||
//foreach (var item in site_list)
|
||||
//{
|
||||
// RadioButton rb = new RadioButton();
|
||||
// rb.Name = item.SiteID;
|
||||
// rb.Text = item.SiteName;
|
||||
// rb.Tag = item.SiteDB;
|
||||
// rb.Font = new Font(Font.FontFamily, 12);
|
||||
// rb.AutoSize = true;
|
||||
// rb.CheckedChanged += new EventHandler(rb_site_CheckedChanged);
|
||||
// fp_site.Controls.Add(rb);
|
||||
// if (i == 0) rb.Checked = true;
|
||||
// i++;
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="fmArchive.resx" />
|
||||
<EmbeddedResource Remove="fmExcel.resx" />
|
||||
<EmbeddedResource Remove="fmMain.resx" />
|
||||
<EmbeddedResource Remove="fmTest.resx" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user