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