diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs
index 876ed87..da9db0c 100644
--- a/SolarPower/Repository/Implement/OverviewRepository.cs
+++ b/SolarPower/Repository/Implement/OverviewRepository.cs
@@ -237,7 +237,7 @@ namespace SolarPower.Repository.Implement
{
var startDay = Convert.ToDateTime(nowDay).AddDays(-7).ToString("yyyy-MM-dd");
- var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d') AS Label, ps.TODAYKWH AS PowerData, pyr.Irradiance AS IrradianceData, pyr.Temperature AS TemperatureData
+ var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d') AS Label, ps.TODAYKWH AS PowerData, pyr.IrrDayHour AS IrradianceData, pyr.Temperature AS TemperatureData
FROM power_station_history_day ps
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d')
WHERE ps.PowerStationId = @PowerStationId
@@ -262,7 +262,7 @@ namespace SolarPower.Repository.Implement
{
var startDay = Convert.ToDateTime(nowDay).ToString("yyyy-MM-01");
- var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d') AS Label, ps.TODAYKWH AS PowerData, pyr.Irradiance AS IrradianceData, pyr.Temperature AS TemperatureData
+ var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m-%d') AS Label, ps.TODAYKWH AS PowerData, pyr.IrrDayHour AS IrradianceData, pyr.Temperature AS TemperatureData
FROM power_station_history_day ps
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d')
WHERE ps.PowerStationId = @PowerStationId
@@ -288,7 +288,7 @@ namespace SolarPower.Repository.Implement
{
var startyear = Convert.ToDateTime(nowDay).ToString("yyyy");
- var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m') AS Label, ps.MONTHKWH AS PowerData, pyr.Irradiance AS IrradianceData, pyr.Temperature AS TemperatureData
+ var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp, '%Y-%m') AS Label, ps.MONTHKWH AS PowerData, pyr.IrrDay AS IrradianceData, pyr.Temperature AS TemperatureData
FROM power_station_history_month ps
LEFT JOIN sensor_history_month pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m') = DATE_FORMAT(pyr.timestamp, '%Y-%m')
WHERE ps.PowerStationId = @PowerStationId
diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml
index 62c1bb2..af188e6 100644
--- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml
+++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml
@@ -31,7 +31,7 @@
-
27°C
降雨幾率: 0%
+
27°C
降雨機率: 0%
@@ -351,7 +351,7 @@
$('#power-station-healthStatus').html(statusicon);
$('#power-station-title').html(stationOverview.stationName);
- $('#weather-temp').html(stationOverview.todayWeatherTemp + '°C
降雨幾率: ' + stationOverview.rateOfRain + '%');
+ $('#weather-temp').html(stationOverview.todayWeatherTemp + '°C
降雨機率: ' + stationOverview.rateOfRain + '%');
$('#weather-icon')[0].setAttribute("class", 'fal fa-' + stationOverview.todayWeather + ' fa-3x');
$('#breadcrumbname').html(stationOverview.stationName);
$('#breadcrumbcity').html(stationOverview.cityName);
diff --git a/solarApp/Service/archiveLowData.cs b/solarApp/Service/archiveLowData.cs
index 006b20c..85af4be 100644
--- a/solarApp/Service/archiveLowData.cs
+++ b/solarApp/Service/archiveLowData.cs
@@ -6,6 +6,7 @@ using solarApp.Model;
using System.Configuration;
using Dapper;
using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
namespace solarApp.Service
{
@@ -30,11 +31,18 @@ namespace solarApp.Service
public string _siteID01 { get; set; }
public string _powerStationID { get; set; }
+ ///
+ /// 要搬動的月份
+ ///
+ public string move_month { get; set; }
+
public bool archiveData(string siteID)
{
bool result = false;
-
+ // string yyyymm = System.DateTime.Now.AddMonths(-2).ToString("yyyy-MM");
_siteID = siteID;
+ //搬移的月份
+ move_month = System.DateTime.Now.AddMonths(-2).ToString("yyyy-MM");
//_date1 = date1;
get_siteInfo();
checkTable();
@@ -42,6 +50,8 @@ namespace solarApp.Service
moveData_station();
moveData_inv();
moveData_sensor();
+
+
result = true;
return result;
@@ -86,14 +96,14 @@ namespace solarApp.Service
try
{
//先判斷是否存在 DB
- //string ss = $@"SELECT * FROM information_schema.SCHEMATA where SCHEMA_NAME='" + _siteDB + "'; ";
- //List ds_db = conn.Query(ss, new { siteDB = _siteDB }).AsList();
+ string ss = $@"SELECT * FROM information_schema.SCHEMATA where SCHEMA_NAME= '" + _siteDB + "'; ";
+ List ds_db = conn.Query(ss, new { siteDB = _siteDB }).AsList();
////如果該 DB不存在 則create
- //if (ds_db.Count == 0)
- //{
- // string createDb = $@"CREATE SCHEMA '" + _siteDB + "' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
- //}
+ if (ds_db.Count == 0)
+ {
+ string createDb = $@"CREATE DATABASE " + _siteDB + " DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
+ }
//判斷table是否存在
string checkStationExists = $@"SELECT * FROM information_schema.tables WHERE table_schema = '{_siteDB}_history' AND table_name = 's{_siteID01}_station';";
@@ -290,7 +300,7 @@ namespace solarApp.Service
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】開始執行[{_siteDB}.s{_siteID}_station]的資料表向[{_siteDB}_history.s{_siteID}_station]搬移");
string for_insert_station = $@"INSERT {_siteDB}_history.s{_siteID01}_station(`ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `KWH`, `TODAYKWH`, `TOTALKWH`, `KWHKWP`, `PR`, `MP`, `SOLARHOUR`, `insertTime`)
SELECT `ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `KWH`, `TODAYKWH`, `TOTALKWH`, `KWHKWP`, `PR`, `MP`, `SOLARHOUR`, `insertTime` FROM {_siteDB}.s{_siteID01}_station
- WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '2022-10'";
+ WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '{move_month}'";
int rowCT = conn.Execute(for_insert_station, commandTimeout : 600);
// System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】{_siteDB}.s{_siteID}_station的七月前資料寫入至{_siteDB}_history.s{_siteID}_station【寫入成功】於{dateTime}");
@@ -303,7 +313,7 @@ namespace solarApp.Service
//刪除原本的資料
string for_delete_station = $@"DELETE FROM {_siteDB}.s{_siteID01}_station
- WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '2022-10'";
+ WHERE FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') < '{move_month}'";
rowCT = conn.Execute(for_delete_station, commandTimeout: 600);
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】{_siteDB}.s{_siteID}_sensoravg搬移至{_siteDB}_history.s{_siteID}_sensoravg【搬移資料成功】於{dateTime} 共 {delete_station.ToString()} 筆");
duration = DateTime.Now - dt_start1;
@@ -343,10 +353,14 @@ namespace solarApp.Service
{
#region inv搬移
dt_start1 = DateTime.Now;
+ if (_powerStationID == "19")
+ {
+ //MessageBox.Show("here");
+ }
// System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】開始執行[{_siteDB}.s{_siteID}_inv]的資料表向[{_siteDB}_history.s{_siteID}_inv]搬移");
string for_insert_inv = $@"INSERT {_siteDB}_history.s{_siteID01}_inv(`ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `INVERTERID`, `SN`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `ACRUNTIME`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `DCRUNTIME`, `WH`, `TODAYKWH`, `TOTALKWH`, `PR`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `CrdTime`)
SELECT `ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `INVERTERID`, `SN`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `ACRUNTIME`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `DCRUNTIME`, `WH`, `TODAYKWH`, `TOTALKWH`, `PR`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `CrdTime` FROM {_siteDB}.s{_siteID01}_inv
- WHERE LEFT(crdTime, 7) < '2022-10'";
+ WHERE LEFT(crdTime, 7) < '{move_month}'";
int rowCT = conn.Execute(for_insert_inv, commandTimeout: 6000);
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】{_siteDB}.s{_siteID}_inv的七月前資料寫入至{_siteDB}_history.s{_siteID}_inv【寫入成功】於{dateTime}");
// log
@@ -356,7 +370,7 @@ namespace solarApp.Service
dt_start1 = DateTime.Now;
string for_delete_inv = $@"DELETE FROM {_siteDB}.s{_siteID01}_inv
- WHERE LEFT(crdTime, 7) < '2022-10'";
+ WHERE LEFT(crdTime, 7) < '{move_month}'";
rowCT = conn.Execute(for_delete_inv, commandTimeout: 6000);
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】{_siteDB}.s{_siteID}_sensoravg搬移至{_siteDB}_history.s{_siteID}_sensoravg【搬移資料成功】於{dateTime} 共 {delete_inv.ToString()} 筆");
duration = DateTime.Now - dt_start1;
@@ -390,15 +404,16 @@ namespace solarApp.Service
dt_start1 = DateTime.Now;
//System.Diagnostics.Debug.WriteLine($"【ArchiveRowData】開始執行[{_siteDB}.s{_siteID}_sensoravg]的資料表向[{_siteDB}_history.s{_siteID}_sensoravg]搬移");
string for_insert_sensoravg = $@"INSERT {_siteDB}_history.s{_siteID01}_sensoravg(`ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `SENSORAVG01`, `SENSORAVG02`, `SENSORAVG03`, `SENSORAVG04`, `SENSORAVG05`, `SENSORAVG06`, `SENSORAVG07`, `SENSORAVG08`, `SENSORAVG09`, `SENSORAVG10`, `SENSORAVG11`, `SENSORAVG12`, `SENSORAVG13`, `SENSORAVG14`, `SENSORAVG15`, `SENSORAVG16`, `SENSORAVG17`, `SENSORAVG18`, `SENSORAVG19`, `SENSORAVG20`, `SENSORAVG21`, `SENSORAVG22`, `SENSORAVG23`, `SENSORAVG24`, `SENSORAVG25`, `SENSORAVG26`, `SENSORAVG27`, `SENSORAVG28`, `SENSORAVG29`, `SENSORAVG30`, `SENSORAVG31`, `SENSORAVG32`, `SENSORAVG33`, `SENSORAVG34`, `SENSORAVG35`, `SENSORAVG36`, `SENSORAVG37`, `SENSORAVG38`, `SENSORAVG39`, `SENSORAVG40`, `SENSORAVG41`, `SENSORAVG42`, `SENSORAVG43`, `SENSORAVG44`, `SENSORAVG45`, `SENSORAVG46`, `SENSORAVG47`, `SENSORAVG48`, `SENSORAVG49`, `SENSORAVG50`, `CrdTime`)
- SELECT `ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `SENSORAVG01`, `SENSORAVG02`, `SENSORAVG03`, `SENSORAVG04`, `SENSORAVG05`, `SENSORAVG06`, `SENSORAVG07`, `SENSORAVG08`, `SENSORAVG09`, `SENSORAVG10`, `SENSORAVG11`, `SENSORAVG12`, `SENSORAVG13`, `SENSORAVG14`, `SENSORAVG15`, `SENSORAVG16`, `SENSORAVG17`, `SENSORAVG18`, `SENSORAVG19`, `SENSORAVG20`, `SENSORAVG21`, `SENSORAVG22`, `SENSORAVG23`, `SENSORAVG24`, `SENSORAVG25`, `SENSORAVG26`, `SENSORAVG27`, `SENSORAVG28`, `SENSORAVG29`, `SENSORAVG30`, `SENSORAVG31`, `SENSORAVG32`, `SENSORAVG33`, `SENSORAVG34`, `SENSORAVG35`, `SENSORAVG36`, `SENSORAVG37`, `SENSORAVG38`, `SENSORAVG39`, `SENSORAVG40`, `SENSORAVG41`, `SENSORAVG42`, `SENSORAVG43`, `SENSORAVG44`, `SENSORAVG45`, `SENSORAVG46`, `SENSORAVG47`, `SENSORAVG48`, `SENSORAVG49`, `SENSORAVG50`, `CrdTime` FROM {_siteDB}.s{_siteID01}_sensoravg
- WHERE LEFT(crdTime, 7) < '2022-10'";
+ SELECT `ID`, `TIMESTAMP`, `SITEID`, `SITETYPE`, `CONTROLLERID`, `SENSORAVG01`, `SENSORAVG02`, `SENSORAVG03`, `SENSORAVG04`, `SENSORAVG05`, `SENSORAVG06`, `SENSORAVG07`, `SENSORAVG08`, `SENSORAVG09`, `SENSORAVG10`, `SENSORAVG11`, `SENSORAVG12`, `SENSORAVG13`, `SENSORAVG14`, `SENSORAVG15`, `SENSORAVG16`, `SENSORAVG17`, `SENSORAVG18`, `SENSORAVG19`, `SENSORAVG20`, `SENSORAVG21`, `SENSORAVG22`, `SENSORAVG23`, `SENSORAVG24`, `SENSORAVG25`, `SENSORAVG26`, `SENSORAVG27`, `SENSORAVG28`, `SENSORAVG29`, `SENSORAVG30`, `SENSORAVG31`, `SENSORAVG32`, `SENSORAVG33`, `SENSORAVG34`, `SENSORAVG35`, `SENSORAVG36`, `SENSORAVG37`, `SENSORAVG38`, `SENSORAVG39`, `SENSORAVG40`, `SENSORAVG41`, `SENSORAVG42`, `SENSORAVG43`, `SENSORAVG44`, `SENSORAVG45`, `SENSORAVG46`, `SENSORAVG47`, `SENSORAVG48`, `SENSORAVG49`, `SENSORAVG50`, `CrdTime`
+ FROM {_siteDB}.s{_siteID01}_sensoravg
+ WHERE LEFT(crdTime, 7) < '{move_month}'";
int rowCT = conn.Execute(for_insert_sensoravg, commandTimeout: 600);
// log
TimeSpan duration = DateTime.Now - dt_start1;
arclog.insert_log(_powerStationID, "move raw s1", duration.TotalSeconds, $"{_siteDB}.s{_siteID01}_sensoravg", $"{_siteDB}_history.s{_siteID01}_sensoravg", "0", "", rowCT.ToString(), conn, null);
dt_start1 = DateTime.Now;
- string for_delete_sensoravg = $@"DELETE FROM {_siteDB}.s{_siteID01}_sensoravg WHERE LEFT(crdTime, 7) < '2022-10'";
+ string for_delete_sensoravg = $@"DELETE FROM {_siteDB}.s{_siteID01}_sensoravg WHERE LEFT(crdTime, 7) < '{move_month}'";
rowCT = conn.Execute(for_delete_sensoravg, commandTimeout: 600);
duration = DateTime.Now - dt_start1;
diff --git a/solarApp/Service/getStationSvc.cs b/solarApp/Service/getStationSvc.cs
index a1dcae4..4e39e26 100644
--- a/solarApp/Service/getStationSvc.cs
+++ b/solarApp/Service/getStationSvc.cs
@@ -193,7 +193,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 ";
// id <> 14";and id > 24
List ds = conn.Query(sql).AsList();
conn.Close();
diff --git a/solarApp/Service/procSensorSvc.cs b/solarApp/Service/procSensorSvc.cs
index 992ed17..a9c4d76 100644
--- a/solarApp/Service/procSensorSvc.cs
+++ b/solarApp/Service/procSensorSvc.cs
@@ -559,6 +559,10 @@ namespace solarApp.Service
return result;
}
+ ///
+ /// 累計日照計算
+ ///
+ ///
bool insert_sensor_for_history_hour()
{
procArchiveLog arclog = new procArchiveLog();
@@ -581,9 +585,9 @@ namespace solarApp.Service
if (isFirst)
{
sql = $@"DROP TEMPORARY TABLE IF EXISTS `temp_s1`;
- create TEMPORARY TABLE temp_s1
- select powerstationID, `TIMESTAMP`, irrday
- from sensor_history_hour a
+ Create TEMPORARY TABLE temp_s1
+ Select powerstationID, `TIMESTAMP`, irrday
+ From sensor_history_hour a
where LEFT(a.TIMESTAMP, 10 ) = '{_date1}';
ALTER TABLE `temp_s1` ADD INDEX `temp_indexs1` (powerstationID, `TIMESTAMP`);";
dt_start2 = DateTime.Now;
@@ -597,9 +601,8 @@ namespace solarApp.Service
sql = $@" update sensor_history_hour a join
(select powerstationID, LEFT(DATE_ADD(`TIMESTAMP`, INTERVAL +1 hour), 13) hour_1, irrday from temp_s1 ) b
on LEFT(a.`TIMESTAMP`, 13) = hour_1 and a.powerstationID = b.powerstationID
- Set irrDayhour = case when a.`irrday` - b.`irrday` < 0 then 0 else a.`irrday` - b.`irrday` end
- where LEFT(a.TIMESTAMP, 10 ) = '{_date1}'
- and a.powerstationID = {_powerStationID} ";
+ Set irrDayhour = case when a.`irrday` - b.`irrday` < 0 then 0 else a.`irrday` - b.`irrday` end
+ where LEFT(a.TIMESTAMP, 10 ) = '{_date1}' and a.powerstationID = {_powerStationID} ";
dt_start2 = DateTime.Now;
cmd.CommandText = sql;
int rowCT2 = cmd.ExecuteNonQuery();
diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs
index 64777bc..248aab2 100644
--- a/solarApp/Service/procSyncError.cs
+++ b/solarApp/Service/procSyncError.cs
@@ -44,7 +44,7 @@ namespace solarApp.Service
// a.`acktime` = b.`acktime`,
// a.`lastupdate` = b.`lastupdate`
// where b.datestamp >= '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}'";// and a.site_id is not null "; // ;";
- string ss = $@" update`err_main` a join alarmorion_orionalarmrecord b on a.id = b.id set
+ string ss = $@" update `err_main` a join alarmorion_orionalarmrecord b on a.id = b.id set
a.`sourcestate` = b.`sourcestate`,
a.`ackstate` = b.`ackstate`,
a.`priority` = b.`priority`,
diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs
index b279830..4d4817b 100644
--- a/solarApp/fmArchive.cs
+++ b/solarApp/fmArchive.cs
@@ -312,6 +312,7 @@ namespace solarApp
procInvSvc invSvc = new procInvSvc();
procStationSvc siteSvc = new procStationSvc();
+
foreach (var item in site_list)
{
//RadioButton rb = new RadioButton();
diff --git a/solarApp/solarApp.csproj b/solarApp/solarApp.csproj
index 2877e20..9e163a5 100644
--- a/solarApp/solarApp.csproj
+++ b/solarApp/solarApp.csproj
@@ -14,7 +14,6 @@
-