修正 天氣資訊- 溫度為0的問題
This commit is contained in:
parent
84dc9a296d
commit
a31712020b
@ -355,11 +355,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
"today_carbon",
|
||||
"total_carbon",
|
||||
"today_irradiance",
|
||||
"SolarHour",
|
||||
"WeathersStationId",
|
||||
"TodayWeatherTemp",
|
||||
"TodayWeather",
|
||||
"RateOfRain"
|
||||
"SolarHour"
|
||||
};
|
||||
logger.LogInformation("【update Power_Station】【ArchiveStation】【開始更新 Power_Station 資料】- {0}", dateTime);
|
||||
await powerStationRepository.UpdateList(calcPowerStations, power_station_properties);
|
||||
@ -733,6 +729,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
Root2 observation = null;
|
||||
List<WeatherObservation> weatherObservations = new List<WeatherObservation>();
|
||||
List<PowerStation> calcPowerStations = new List<PowerStation>();
|
||||
#region 氣象觀測(取資料)
|
||||
try
|
||||
{
|
||||
@ -760,7 +757,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
#region 確認是否有觀測站(沒有則新增)
|
||||
try
|
||||
{
|
||||
if (powerStation.WeathersStationId == null)
|
||||
if (powerStation.WeathersStationId == null || powerStation.TodayWeatherTemp == -99)
|
||||
{
|
||||
var weatherStationId = "";
|
||||
double shortLocation = 9999;
|
||||
@ -777,7 +774,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
double x = Math.Pow(p1 - dLat, 2);
|
||||
double y = Math.Pow(p2 - dLon, 2);
|
||||
var nowLocation = Math.Sqrt(x + y);
|
||||
if (nowLocation < shortLocation)
|
||||
double temp = Convert.ToDouble(Location.WeatherElement[0].ElementValue);
|
||||
if (nowLocation < shortLocation && temp != -99)
|
||||
{
|
||||
shortLocation = nowLocation;
|
||||
weatherStationId = Location.StationId;
|
||||
@ -816,6 +814,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
calcPowerStation.TodayWeather = weather.WeatherKey;
|
||||
calcPowerStation.RateOfRain = weather.PoP;
|
||||
}
|
||||
calcPowerStations.Add(calcPowerStation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -846,6 +845,20 @@ namespace SolarPower.Quartz.Jobs
|
||||
await powerStationRepository.AddWeatherObservation(weatherObservations, weather_observation_properties);
|
||||
logger.LogInformation("【Insert WeatherObservation】【ArchiveWeather】【完成寫入 weather_observation 資料】- {0}", dateTime);
|
||||
#endregion
|
||||
|
||||
#region step5. calcPowerStations UPDATE 到 power_station 資料表
|
||||
List<string> power_station_properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"WeathersStationId",
|
||||
"TodayWeatherTemp",
|
||||
"TodayWeather",
|
||||
"RateOfRain"
|
||||
};
|
||||
logger.LogInformation("【update Power_Station Weather】【ArchiveStation】【開始更新 Power_Station 資料】- {0}", dateTime);
|
||||
await powerStationRepository.UpdateList(calcPowerStations, power_station_properties);
|
||||
logger.LogInformation("【update Power_Station Weather】【ArchiveStation】【完成更新 Power_Station 資料】- {0}", dateTime);
|
||||
#endregion
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user