feat: Implement multi-source weather data collection with caching, rate limiting, and disk persistence.

This commit is contained in:
2569718930@qq.com
2026-03-20 13:35:34 +08:00
parent da9b0b36f7
commit dbf10253a8
7 changed files with 239 additions and 91 deletions
+21
View File
@@ -18,3 +18,24 @@ def wu_round(value: Optional[Number]) -> Optional[int]:
return int(math.floor(x + 0.5))
return int(math.ceil(x - 0.5))
def is_exact_settlement_city(city: str) -> bool:
"""是否为不四舍五入的精确结算城市"""
if not city:
return False
c = str(city).lower().strip()
return c in ["hong kong", "hk", "taipei", "tpe", "臺北", "台北", "香港"]
def apply_city_settlement(city: str, value: Optional[Number]) -> Optional[int]:
"""
根据城市返回最终的结算值:
- 香港/台北: 向下取整 (e.g. 28.9 -> 28)
- 其他: WU 规则四舍五入
"""
if value is None:
return None
if is_exact_settlement_city(city):
return int(math.floor(float(value)))
return wu_round(value)