1. 每月sensor avg bug fix
This commit is contained in:
parent
933db5000b
commit
bdd92e27c0
@ -1779,6 +1779,195 @@ ALTER TABLE `power_station`
|
|||||||
CHANGE COLUMN `today_monery` `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`,
|
CHANGE COLUMN `today_monery` `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`,
|
||||||
CHANGE COLUMN `total_monery` `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_money`;
|
CHANGE COLUMN `total_monery` `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_money`;
|
||||||
|
|
||||||
|
-- 各電站每小時的sensor avg 歷史資料 20210721
|
||||||
|
CREATE TABLE `sensoravg_history_hour` (
|
||||||
|
`Id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
|
||||||
|
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG01` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG02` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG03` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG04` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG05` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG06` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG07` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG08` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG09` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG10` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG11` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG12` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG13` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG14` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG15` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG16` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG17` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG18` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG19` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG20` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG21` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG22` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG23` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG24` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG25` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG26` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG27` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG28` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG29` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG30` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG31` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG32` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG33` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG34` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG35` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG36` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG37` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG38` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG39` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG40` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG41` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG42` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG43` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG44` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG45` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG46` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG47` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG48` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG49` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG50` DOUBLE NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`Id`) USING BTREE
|
||||||
|
)
|
||||||
|
COMMENT='各電站每小時的sensor avg 歷史資料'
|
||||||
|
COLLATE='utf8mb4_unicode_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 各電站每天的sensor avg 歷史資料 20210721
|
||||||
|
CREATE TABLE `sensoravg_history_day` (
|
||||||
|
`Id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
|
||||||
|
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG01` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG02` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG03` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG04` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG05` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG06` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG07` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG08` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG09` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG10` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG11` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG12` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG13` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG14` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG15` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG16` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG17` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG18` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG19` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG20` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG21` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG22` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG23` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG24` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG25` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG26` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG27` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG28` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG29` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG30` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG31` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG32` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG33` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG34` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG35` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG36` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG37` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG38` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG39` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG40` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG41` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG42` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG43` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG44` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG45` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG46` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG47` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG48` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG49` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG50` DOUBLE NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`Id`) USING BTREE
|
||||||
|
)
|
||||||
|
COMMENT='各電站每天的sensor avg 歷史資料'
|
||||||
|
COLLATE='utf8mb4_unicode_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 各電站每月的sensor avg 歷史資料 20210721
|
||||||
|
CREATE TABLE `sensoravg_history_month` (
|
||||||
|
`Id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
|
||||||
|
`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG01` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG02` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG03` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG04` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG05` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG06` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG07` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG08` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG09` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG10` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG11` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG12` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG13` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG14` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG15` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG16` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG17` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG18` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG19` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG20` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG21` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG22` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG23` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG24` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG25` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG26` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG27` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG28` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG29` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG30` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG31` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG32` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG33` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG34` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG35` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG36` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG37` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG38` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG39` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG40` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG41` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG42` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG43` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG44` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG45` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG46` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG47` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG48` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG49` DOUBLE NULL DEFAULT NULL,
|
||||||
|
`SENSORAVG50` DOUBLE NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`Id`) USING BTREE
|
||||||
|
)
|
||||||
|
COMMENT='各電站每月的sensor avg 歷史資料'
|
||||||
|
COLLATE='utf8mb4_unicode_ci'
|
||||||
|
ENGINE=InnoDB
|
||||||
|
AUTO_INCREMENT=2
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
|||||||
@ -535,7 +535,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
//電站該月份的的sensoravg歷史資料
|
//電站該月份的的sensoravg歷史資料
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始計算電站[{0}]在{1}月份的Sensor Avg table所有值的平均資料】", powerStation.Code, dateNowMonth);
|
||||||
var exist_sensoravg_history = await powerStationRepository.GetSensorAvgHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
var exist_sensoravg_history = await powerStationRepository.GetSensorAvgHistoryByPowerStationIdAndMonth(dateNowMonth, powerStation.Id);
|
||||||
if (exist_sensoravg_history != null)
|
if (exist_sensoravg_history == null)
|
||||||
{ //新增
|
{ //新增
|
||||||
var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
var sensorAvgHistoryMonth = await powerStationRepository.CalcSensorAvgHistoryMonthDataByPowerStationId(dateNowMonth, powerStation.Id);
|
||||||
if (sensorAvgHistoryMonth != null)
|
if (sensorAvgHistoryMonth != null)
|
||||||
@ -588,7 +588,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
await powerStationRepository.UpdatePowerStationHistoryMonthList(updatePowerStationHistoryMonths);
|
await powerStationRepository.UpdatePowerStationHistoryMonthList(updatePowerStationHistoryMonths);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region step5. 將各電站的每日及月的日照度資料insert or update 各資料表
|
#region step5. 將各電站的每月的日照度資料insert or update 各資料表
|
||||||
|
|
||||||
//每月
|
//每月
|
||||||
if (insertPyrheliometerHistoryMonths.Count > 0)
|
if (insertPyrheliometerHistoryMonths.Count > 0)
|
||||||
|
|||||||
@ -460,7 +460,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
await powerStationRepository.AddInverterHistory(inverterHistories, inverter_history_properties);
|
await powerStationRepository.AddInverterHistory(inverterHistories, inverter_history_properties);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region step6. 將 inverter INSERT 到 inverter_history_hour 資料表
|
#region step6. 將 sensoravg INSERT 到 sensoravg_history_hour 資料表
|
||||||
List<string> sensoravg_history_properties = new List<string>()
|
List<string> sensoravg_history_properties = new List<string>()
|
||||||
{
|
{
|
||||||
"PowerStationId",
|
"PowerStationId",
|
||||||
|
|||||||
@ -3337,13 +3337,12 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
if (i < 10)
|
if (i < 10)
|
||||||
{
|
{
|
||||||
sensor_str += "AVG(SENSORAVG" + "0" + i.ToString() + "),";
|
sensor_str += "AVG(SENSORAVG" + "0" + i.ToString() + ") AS SENSORAVG" + "0" + i.ToString() + ",";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sensor_str += "AVG(SENSORAVG" + i.ToString() + "),";
|
sensor_str += "AVG(SENSORAVG" + i.ToString() + ") AS SENSORAVG" + i.ToString() + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_str = sensor_str.Substring(0, sensor_str.Length - 1);
|
sensor_str = sensor_str.Substring(0, sensor_str.Length - 1);
|
||||||
@ -3376,7 +3375,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string sql = GenerateInsertQueryWithCustomTable(properties, "weather_forecast");
|
string sql = GenerateInsertQueryWithCustomTable(properties, "sensoravg_history_hour");
|
||||||
|
|
||||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||||
|
|
||||||
@ -3409,23 +3408,23 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
if (i < 10)
|
if (i < 10)
|
||||||
{
|
{
|
||||||
sensor_str += "AVG(SENSORAVG" + "0" + i.ToString() + "),";
|
sensor_str += "AVG(SENSORAVG" + "0" + i.ToString() + ") AS SENSORAVG" + "0" + i.ToString() + ",";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sensor_str += "AVG(SENSORAVG" + i.ToString() + "),";
|
sensor_str += "AVG(SENSORAVG" + i.ToString() + ") AS SENSORAVG" + i.ToString() + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_str = sensor_str.Substring(0, sensor_str.Length - 1);
|
sensor_str = sensor_str.Substring(0, sensor_str.Length - 1);
|
||||||
|
|
||||||
var sql = @$"SELECT
|
var sql = @$"SELECT
|
||||||
DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
PowerStationId,
|
||||||
|
DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
||||||
{sensor_str}
|
{sensor_str}
|
||||||
FROM sensoravg_history_hour
|
FROM sensoravg_history_hour
|
||||||
WHERE PowerStationId = @PowerStationId
|
WHERE PowerStationId = @PowerStationId
|
||||||
AND DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') = @NowDay
|
AND DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') = @NowDay
|
||||||
GROUP BY DATE_FORMAT(timestamp, '%Y-%m-%d')";
|
GROUP BY DATE_FORMAT(timestamp, '%Y-%m-%d')";
|
||||||
|
|
||||||
|
|
||||||
@ -3500,18 +3499,18 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
if (i < 10)
|
if (i < 10)
|
||||||
{
|
{
|
||||||
sensor_str += "AVG(SENSORAVG" + "0" + i.ToString() + "),";
|
sensor_str += "AVG(SENSORAVG" + "0" + i.ToString() + ") AS SENSORAVG" + "0" + i.ToString() + ",";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sensor_str += "AVG(SENSORAVG" + i.ToString() + "),";
|
sensor_str += "AVG(SENSORAVG" + i.ToString() + ") AS SENSORAVG" + i.ToString() + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_str = sensor_str.Substring(0, sensor_str.Length - 1);
|
sensor_str = sensor_str.Substring(0, sensor_str.Length - 1);
|
||||||
|
|
||||||
var sql = @$"SELECT
|
var sql = @$"SELECT
|
||||||
|
PowerStationId,
|
||||||
DATE_FORMAT(TIMESTAMP, '%Y-%m') AS TIMESTAMP,
|
DATE_FORMAT(TIMESTAMP, '%Y-%m') AS TIMESTAMP,
|
||||||
{sensor_str}
|
{sensor_str}
|
||||||
FROM sensoravg_history_day
|
FROM sensoravg_history_day
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user