solar_App: test 修改 irrDayHour In TPY
This commit is contained in:
parent
b053f20bbe
commit
6179d549a4
@ -44,7 +44,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
|
|
||||||
if (this.environment.IsDevelopment())
|
if (this.environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
dateTime = "2022-06-01 16";
|
dateTime = "2022-08-04 18";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
|
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
|
||||||
@ -491,6 +491,14 @@ 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);
|
||||||
|
TPYHistory = await powerStationRepository.CalcIrrDayHourHistoryPerHour(dateTime, powerStation.Id);
|
||||||
|
if (TPYHistory != null)
|
||||||
|
{
|
||||||
|
sensorHistory.IrrDayHour = TPYHistory.IrrDayHour;
|
||||||
|
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -501,28 +509,28 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
|
|
||||||
//9. 計算該電站 - 每小時累計日照量(IrrDayHour)
|
//9. 計算該電站 - 每小時累計日照量(IrrDayHour)
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的累計日照量設備資訊】", powerStation.Code, dateTime);
|
// logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的累計日照量設備資訊】", powerStation.Code, dateTime);
|
||||||
var TPYdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.TPY.ToString(), powerStation.SiteDB);
|
// var TPYdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.TPY.ToString(), powerStation.SiteDB);
|
||||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的累計日照量備資訊】", powerStation.Code, dateTime);
|
// logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的累計日照量備資訊】", powerStation.Code, dateTime);
|
||||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的相減的累計日照量設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(TPYdeviceInfos));
|
// logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的相減的累計日照量設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(TPYdeviceInfos));
|
||||||
if (TPYdeviceInfos != null && TPYdeviceInfos.Count() > 0)
|
// if (TPYdeviceInfos != null && TPYdeviceInfos.Count() > 0)
|
||||||
{
|
// {
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
// logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
||||||
var TPYHistory = await powerStationRepository.CalcIrrDayHourHistoryPerHour(dateTime, powerStation.Id);
|
// var TPYHistory = await powerStationRepository.CalcIrrDayHourHistoryPerHour(dateTime, powerStation.Id);
|
||||||
if (TPYHistory != null)
|
// if (TPYHistory != null)
|
||||||
{
|
// {
|
||||||
sensorHistory.IrrDayHour = TPYHistory.IrrDayHour;
|
// sensorHistory.IrrDayHour = TPYHistory.IrrDayHour;
|
||||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
// logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
catch (Exception ex)
|
//catch (Exception ex)
|
||||||
{
|
//{
|
||||||
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
// logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的相減的累計日照量】", powerStation.Code, dateTime);
|
||||||
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
|
// logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
|
||||||
}
|
//}
|
||||||
|
|
||||||
sensorHistoriesHour.Add(sensorHistory);
|
sensorHistoriesHour.Add(sensorHistory);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6433,12 +6433,13 @@ namespace SolarPower.Repository.Implement
|
|||||||
// where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{Convert.ToDateTime(dateTime).ToString("yyyy-MM-dd HH")}'
|
// 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`
|
// ) b on a.powerstationID = b.powerstationID and a.`TIMESTAMP` = b.`TIMESTAMP`
|
||||||
// Set a.irrdayhour = b.irrdayhour where a.powerstationID = {powerStationId}";
|
// Set a.irrdayhour = b.irrdayhour where a.powerstationID = {powerStationId}";
|
||||||
|
string d1 = dateTime + ":00:00";
|
||||||
string sql = $@"update sensor_history_hour a join
|
string sql = $@"update sensor_history_hour a join
|
||||||
(
|
(
|
||||||
select powerstationID, `TIMESTAMP`, irrday -
|
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
|
(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 ) = '{(Convert.ToDateTime(dateTime)).ToString("yyyy-MM-dd HH")}'
|
where powerstationID = {powerStationId} and LEFT(z.`TIMESTAMP`, 13 ) = '{dateTime}'
|
||||||
) b on a.powerstationID = b.powerstationID and a.`TIMESTAMP` = b.`TIMESTAMP`
|
) 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
|
Set a.irrdayhour = case when b.irrdayhour < 0 then 0 else b.irrdayhour end
|
||||||
where a.powerstationID = {powerStationId}";
|
where a.powerstationID = {powerStationId}";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user