網頁每小時更新irrDayHour,算法改為前一小時的IrrDay減掉前兩小時的IrrDay
This commit is contained in:
parent
6934f9acac
commit
7918505b80
@ -608,10 +608,10 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
sensorHistory.IrrDay = TPYHistory.IrrDay;
|
sensorHistory.IrrDay = TPYHistory.IrrDay;
|
||||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的累計日照量的平均值】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的累計日照量的平均值】", powerStation.Code, dateTime);
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
||||||
var ss = await powerStationRepository.CalcIrrDayHourHistoryPerHour(dateTime, powerStation.Id);
|
var twoHourAgoIrrDay = await powerStationRepository.CalcIrrDayHistoryPerTwoHour(dateTime, powerStation.Id);
|
||||||
if (ss != null)
|
if (twoHourAgoIrrDay != null)
|
||||||
{
|
{
|
||||||
sensorHistory.IrrDayHour = double.Parse(ss);
|
sensorHistory.IrrDayHour = sensorHistory.IrrDay - double.Parse(twoHourAgoIrrDay);// 前一小時的IrrDay - 前兩小時的IrrDay
|
||||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,98 +1073,5 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task setHistoryPerHourForPowerStation(string dateTime, string full_table_name, PowerStation powerStation)
|
|
||||||
{
|
|
||||||
var calcPowerStation = new PowerStation();
|
|
||||||
calcPowerStation.Id = powerStation.Id;
|
|
||||||
var history_for_powerStation = await powerStationRepository.GetPowerStationHistoryPerHourForPowerStation(dateTime, full_table_name);
|
|
||||||
if (history_for_powerStation == null)
|
|
||||||
{
|
|
||||||
//logger.LogWarning("【CalcPowerStationJob】【查無電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
|
||||||
//每小時發電量(直接填寫
|
|
||||||
calcPowerStation.kwh = 0;
|
|
||||||
//今日發電量(直接填寫
|
|
||||||
calcPowerStation.Today_kWh = 0;
|
|
||||||
//總發電量(直接填寫
|
|
||||||
calcPowerStation.Total_kWh = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//每小時發電量(直接填寫
|
|
||||||
calcPowerStation.kwh = history_for_powerStation.KWH;
|
|
||||||
//今日發電量(直接填寫
|
|
||||||
calcPowerStation.Today_kWh = history_for_powerStation.TodayKWh;
|
|
||||||
//總發電量(直接填寫
|
|
||||||
calcPowerStation.Total_kWh = history_for_powerStation.TotalKWH;
|
|
||||||
|
|
||||||
#region 發電金額
|
|
||||||
|
|
||||||
history_for_powerStation.MONEY = history_for_powerStation.KWH * powerStation.PowerRate;
|
|
||||||
history_for_powerStation.TODAYMONEY = history_for_powerStation.TodayKWh * powerStation.PowerRate;
|
|
||||||
history_for_powerStation.TOTALMONEY = history_for_powerStation.TotalKWH * powerStation.PowerRate;
|
|
||||||
|
|
||||||
//即時發電金額
|
|
||||||
switch (powerStation.SolarType)
|
|
||||||
{
|
|
||||||
case (int)SolarTypeEnum.SelfSold: //自建躉售
|
|
||||||
|
|
||||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
|
||||||
calcPowerStation.Today_Money = history_for_powerStation.TodayKWh * powerStation.PowerRate;
|
|
||||||
|
|
||||||
////總發電金額 計算方式:totalkWh * 授電費率
|
|
||||||
calcPowerStation.Total_Money = history_for_powerStation.TotalKWH * powerStation.PowerRate;
|
|
||||||
break;
|
|
||||||
case (int)SolarTypeEnum.HireSold: //租建躉售
|
|
||||||
//找出該電站的所有土地房屋資訊
|
|
||||||
var landBuildings = await powerStationRepository.GetAllLandBuildingInfoByPowerStationId(powerStation.Id, powerStation.SiteDB);
|
|
||||||
var sumLeaseRate = 0.00;
|
|
||||||
var avgLeaseRate = 0.00;
|
|
||||||
|
|
||||||
foreach (var landBuilding in landBuildings)
|
|
||||||
{
|
|
||||||
sumLeaseRate += landBuilding.LeaseRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
calcPowerStation.Today_Money = history_for_powerStation.TodayKWh * powerStation.PowerRate * sumLeaseRate / 100;
|
|
||||||
calcPowerStation.Total_Money = history_for_powerStation.TotalKWH * powerStation.PowerRate * sumLeaseRate / 100;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case (int)SolarTypeEnum.SelfUse: //自建自用
|
|
||||||
|
|
||||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
|
||||||
calcPowerStation.Today_Money = history_for_powerStation.TodayKWh * powerStation.PowerRate;
|
|
||||||
|
|
||||||
//總發電金額 計算方式:totalkWh * 授電費率
|
|
||||||
calcPowerStation.Total_Money = history_for_powerStation.TotalKWH * powerStation.PowerRate;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region PR
|
|
||||||
//直接填寫
|
|
||||||
calcPowerStation.Today_PR = history_for_powerStation.PR;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 減碳量
|
|
||||||
carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
|
|
||||||
|
|
||||||
history_for_powerStation.CARBON = history_for_powerStation.KWH * carbonRate;
|
|
||||||
history_for_powerStation.TODAYCARBON = history_for_powerStation.TodayKWh * carbonRate;
|
|
||||||
history_for_powerStation.TOTALCARBON = history_for_powerStation.TotalKWH * carbonRate;
|
|
||||||
|
|
||||||
//今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值]
|
|
||||||
calcPowerStation.Today_Carbon = history_for_powerStation.TodayKWh * carbonRate;
|
|
||||||
|
|
||||||
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
|
|
||||||
calcPowerStation.Total_Carbon = history_for_powerStation.TotalKWH * carbonRate;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 發電時間
|
|
||||||
calcPowerStation.SolarHour = history_for_powerStation.SolarHour;
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6539,36 +6539,21 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> CalcIrrDayHourHistoryPerHour(string dateTime, int powerStationId)
|
public async Task<string> CalcIrrDayHistoryPerTwoHour(string dateTime, int powerStationId)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//var sql = $@"update sensor_history_hour a join
|
|
||||||
// (
|
|
||||||
// select powerstationID, `TIMESTAMP`, irrday -
|
|
||||||
// (select irrday from sensor_history_hour where powerstationID = {powerStationId} and LEFT(`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(dateTime).AddHours(-1).ToString("yyyy-MM-dd HH")}' limit 1) irrdayhour
|
|
||||||
// from sensor_history_hour z
|
|
||||||
// where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(dateTime).ToString("yyyy-MM-dd HH")}'
|
|
||||||
// ) b on a.powerstationID = b.powerstationID and a.`TIMESTAMP` = b.`TIMESTAMP`
|
|
||||||
// Set a.irrdayhour = b.irrdayhour where a.powerstationID = {powerStationId}";
|
|
||||||
string d1 = dateTime + ":00:00";
|
string d1 = dateTime + ":00:00";
|
||||||
//string sql = $@"update sensor_history_hour a join
|
//string sql = $@" select irrday -
|
||||||
// (
|
// (select irrday from sensor_history_hour where powerstationID = {powerStationId} and LEFT(`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(d1).AddHours(-1).ToString("yyyy-MM-dd HH")}' limit 1) irrdayhour
|
||||||
// select powerstationID, `TIMESTAMP`, irrday -
|
// from sensor_history_hour z
|
||||||
// (select irrday from sensor_history_hour where powerstationID = {powerStationId} and LEFT(`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(d1).AddHours(-1).ToString("yyyy-MM-dd HH")}' limit 1) irrdayhour
|
// where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{dateTime}' ";
|
||||||
// from sensor_history_hour z
|
string sql = $@" select IrrDay
|
||||||
// where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{dateTime}'
|
|
||||||
// ) b on a.powerstationID = b.powerstationID and a.`TIMESTAMP` = b.`TIMESTAMP`
|
|
||||||
// Set a.irrdayhour = case when b.irrdayhour < 0 then 0 else b.irrdayhour end
|
|
||||||
// where a.powerstationID = {powerStationId}";
|
|
||||||
//result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, commandTimeout: 600);
|
|
||||||
string sql = $@" select irrday -
|
|
||||||
(select irrday from sensor_history_hour where powerstationID = {powerStationId} and LEFT(`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(d1).AddHours(-1).ToString("yyyy-MM-dd HH")}' limit 1) irrdayhour
|
|
||||||
from sensor_history_hour z
|
from sensor_history_hour z
|
||||||
where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{dateTime}' ";
|
where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(d1).AddHours(-1).ToString("yyyy-MM-dd HH")}' ";
|
||||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, commandTimeout: 600);
|
result = await conn.QueryFirstOrDefaultAsync<string>(sql, commandTimeout: 600);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
|||||||
@ -641,7 +641,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task AlertColStationTableColumn(string dbname, string code);
|
Task AlertColStationTableColumn(string dbname, string code);
|
||||||
|
|
||||||
Task<List<PowerStation>> GetAllNoStatusAsync();
|
Task<List<PowerStation>> GetAllNoStatusAsync();
|
||||||
Task<string> CalcIrrDayHourHistoryPerHour(string dateTime, int powerStationId);
|
Task<string> CalcIrrDayHistoryPerTwoHour(string dateTime, int powerStationId);
|
||||||
Task<PowerStationHistory> GetPowerStationHistoryPerHourForPowerStation(string dateTime, string table_name);
|
Task<PowerStationHistory> GetPowerStationHistoryPerHourForPowerStation(string dateTime, string table_name);
|
||||||
Task<InverterTable> GetOneMasterInverter(int id, string db_name);
|
Task<InverterTable> GetOneMasterInverter(int id, string db_name);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user